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.
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
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.
January 7, 2009 1:39 PM
January 7, 2009 8:49 PM