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?
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
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.