September 11, 2014 at 10:01 am
Hi,
can someone share a simple stored procedure example to pass table name as output and output as cursor ?
sample query need to use in procuderure:
SELECT top 10 name from sys.objects
i want to pass table name as input and the output resultset to be stored in cursor.
Thanks,
Kumar
September 11, 2014 at 10:05 am
skrknarayana (9/11/2014)
Hi,can someone share a simple stored procedure example to pass table name as output and output as cursor ?
sample query need to use in procuderure:
SELECT top 10 name from sys.objects
i want to pass table name as input and the output resultset to be stored in cursor.
Thanks,
Kumar
A cursor is not a storage mechanism. It is a very slow way to traverse rows one at a time. It is unclear what you want. Your query for sys.objects would only return 1 row if you filter that to a tablename.
What are you really trying to do here? We can help find a solution that is not using a cursor.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
September 11, 2014 at 10:14 am
If my guessing skills are working fine, you want a result set which in some coding languages is called a cursor. A cursor in SQL Server is very different and can't be returned as an output from a stored procedure.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply