Hi,
I've been told to never use cursor in SQL, because of possibility of memory leak, etc. But I have no idea of how to implement my script without them. My script doesn't execute anything on the database, it simply use cursor to create another TSQL script that does the execution.
EG.
open cursor to get all the user database
get the name of the database
while cursor isn't empty
print 'sp_detach_db ' + db_name
get next name
close cursor
Does anyone know to how to do this without cursor?
I am also using TSQL script with nested cursor which also doesn't execute anything on the database but only to print executable TSQL statement, should I be doing this?
Thanks in advance.
Software/Hardware used:
ASKED:
January 7, 2009 1:39 PM
UPDATED:
January 7, 2009 8:49 PM