June 6, 2003 at 8:26 am
can i write a cursor in a stored procedure?
June 6, 2003 at 8:49 am
Yes although it may not be the most efficient may of processing the query. Just stick something like this in your procedure:
declare @variable varchar(50)
declare cursor_name cursor for
select column
from table
where....
open cursor_name
fetch next from cursor_name into @variable
while @@fetch_status = 0 begin
/* Add in here other TSQL statments or calls to other procedures */
fetch next from cursor_name into @variable
end
close cursor_name
deallocate cursor_name
For more info look in BOL
Jeremy
June 6, 2003 at 8:54 am
quote:
can i write a cursor in a stored procedure?
Yes you can, anything you can do in a T-SQL can be used within PROCS.
MW
MW
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy