SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Row Type Equivalent in SQL Server
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

naveensingh
Starting Member

India
1 Posts

Posted - 06/04/2004 :  02:50:14  Show Profile  Reply with Quote
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

United Kingdom
22403 Posts

Posted - 06/04/2004 :  05:15:02  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Ireland
2916 Posts

Posted - 06/04/2004 :  05:25:18  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000