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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detemine nr. of columns of a cursor 1

Status
Not open for further replies.

hbaake

Programmer
Jun 25, 2001
19
NL
Hi!

Is there a way to determine the number of columns (*NOT* the nr. of rows) a cursor will return? I've got a dynamically created cursor and want to know the nr. of columns... Is there something like a @@CURSOR_COLUMNS?

Thanks,
Hugo.
 
Not sure of a global variable like @@CURSOR_COLUMNS without digging around but off the top of my head you could do something like this prior to createing your cursor:

Create #temp_table(varaiable column names)

select count(b.name) from tempdb..sysobjects a, tempdb..syscolumns b
where a.name like '#temp_table%' and a.id = b.id

drop #temp_table

Rick.
 
You can use the built-in system stored procedure, sp_describe_cursor to find the number of columns in the cursors declared in your script or procedure. Read details of usage in SQL BOL or at the following link.

Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top