Skip to main content
3 votes
Accepted

Run TSQL alter db set trustworthy on multiple times

Your command was building the string incorrectly. I've fixed the data type for database name as well. DECLARE @db_name sysname, @command nvarchar(200); DECLARE database_cursor CURSOR FOR ...
Erik Darling's user avatar
  • 41.9k
2 votes
Accepted

SQL Cursor vs WHILE loop

What you showed here, is actually how cursor works. You just repeated the inner workings of a cursor with a set of SQL statements. The first problem I see here, is that the source table can have ...
White Owl's user avatar
  • 853
1 vote
Accepted

Why does a SAVE TRAN outside of a CURSOR loop not work, but inside does?

When you roll back to a save point, that save point is used up. In position A, you only set it once, so it can only be used once. You are allowed to set a save point with the same name more than once. ...
Paul White's user avatar
  • 86.4k
1 vote
Accepted

SQL Server Cursor preceed by IF statement?

Is it advisable to enclose it within an IF check so the CURSOR it is not Declared, Opened, Closed, & Deallocated ? If the source dataset for the cursor contains 0 rows, then these steps of the ...
J.D.'s user avatar
  • 38.1k

Only top scored, non community-wiki answers of a minimum length are eligible