Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to loop through each column in cursor recordset

Status
Not open for further replies.

WayneGretzky

Programmer
Jan 12, 2004
28
US
How can I loop through each field in the current record in a cursor?

I need to essentially do 2 loops. One loops through each record and then inside each record row, I want to perform an insert on each column.

Something like this maybe using a cursor or something else:

For each record in my table (I'll just use the cursor)
For each column in current record for cursor
perform some sql based on the current column value
Next
Next

I guess I just want to know how to do the for each column to cycle through each field in the current cursor's record.
 
What's your database API? (JDBC, ODBC, embedded SQL...?)
 
I need to do this in a stored proc using Transact SQL functions, cursors, etc., not using VB or other UI languages.
 
This will be a sql statement in SQL Server 2005 Integration Services...so it's all in the backend using T-SQL
 
forum183 is the Microsoft SQL Server: Programming forum.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top