Home Forums SQL Server 7,2000 T-SQL Can this be done without using cursor? RE: Can this be done without using cursor?

  • If # of items would vary in time, you'd never get it running with a single select statement.

    I think concatenation would be the rigth approach. Even if you need a full table, you could use the concatenation to create this table...

    Example:

    Create Table #Concat_Table (item_id int, rows varchar(4000))

    Do the concatenation in such a way that concatenated strings were comma separated and inserted into Concat_table... plus, is some way, obtain the max # of items for a single item.

    Then create a table with that # of columns (I think twice # columns plus 1 for item_id).

    And just, with a simple cursor, loop through the concat table performing an EXEC using the comma separated string concatenated in each row as the values section of an insert.

    But, as you'll see... it is not a sinlge select statement...

    Excuse me my poor english... it's not my natural language... I hope I helped you in some way...

    One last thing... does you have any other columm in source table which identifies one (item, qty. price) from another?

    Nicolas