Posted by: techGuy November 20, 2008
Cursor in T-sql
Login in to Rate this Post:     0       ?        
Dont know abt T-sql, but can you store multiple values in @prod ?
if yes, how do u fetch it?
Generally, cursor is used to store multiple values and later fetch it sequentially.
Suppose i want to truncate some talbes then,
cursor tb is select table_name from user_talbes where table_name like "tb%"

this will store all the table names starting with tb in varable tb.
Then i fetch it to truncate one by one.
open tb
loop
fetch tb into tbname
  truncate table '|| tbname ||'
end loop
well the syntax may not be correct.


Read Full Discussion Thread for this article