Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Row Type Equivalent in SQL Server

Author  Topic 

naveensingh
Starting Member

1 Post

Posted - 2004-06-04 : 02:50:14
I have a scenario like , i have select abt 50 column from 3 different tables in a single query.

I have declared a cursor fwith the above sql statement.
I need to loop thru each record.
Since no of columns is 50 its diffuclt to create 50 variable and use
FETCH NEXT FROM <cursor_name> INTO ,variable_list>

I need to declare a %rowtype variable similar to the one we have in ORACLE cursors.Is there any thing equivalent to this in SQL Server.

Help me out

- Naveen Singh.

Kristen
Test

22859 Posts

Posted - 2004-06-04 : 05:15:02
Do you have to use a cursor? Might help to know what you are actually doing in the "loop" in case there is a "different way" in SQL server

To knock-up a list of @ variables for a given table (which you can then cut,paste&butcher!) the following may help, just put the name of your table at the appropriate point

SELECT '@'+ REPLACE(COLUMN_NAME, ' ', '_') + ' = [' + COLUMN_NAME + '],'
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'MyTableNameHere'
ORDER BY ORDINAL_POSITION

Kristen
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2004-06-04 : 05:25:18
Try to stay away from cursors.....their performance 99.9999% of the time sucks.
post a sample of your code (and if possible input data), and a better (faster) solution may arise.
Go to Top of Page
   

- Advertisement -