Home Forums SQL Server 7,2000 T-SQL Converting a single row into Multiple rows RE: Converting a single row into Multiple rows

  • Hi ,

    I am having similar kind of requirement.

    I have a table.

    create table dbo.test(ID int,Price decimal(18,9), Qty decimal(18,9))

    Insert into dbo.test values(1,5000,5000000)

    Insert into dbo.test values(2,3000,50000000)

    Insert into dbo.test values(3,100,50000)

    I need the output in the below format

    ID PRICE QTY

    1 5000 5000000

    2-1 30 5000000

    2-2 30 5000000

    2-3 30 5000000

    2-4 30 5000000

    2-5 30 5000000

    2-6 30 5000000

    2-7 30 5000000

    2-8 30 5000000

    2-9 30 5000000

    2-10 30 5000000

    3 100 50000

    So the Qty limit is : 5,000000

    First record is equal to the limit.So it can appear in the same format as stored in table.

    In Second Record -Qty is 10 times greater than our limit.So all the columns are splitted as shown above

    Third Row - It is within the limit we have set for Qty.So it can appear in the same format as stored in table.

    Any help is appreciated.

    Thanks

    Nisha V Krishnan