I have a very long T-sql script, it is a single batch, something like
DECLARE variables
select into temptable...
cursor...
insert...
update..
as I run the script I have
(1 row(s) affected)
(5 row(s) affected)
[...]
ERROR
(2 row(s) affected)
etc...
I would like to run step by step the script to identify which is the command that gives error, is it possible in Management Studio without using Visual Studio?
Which other trick can you suggest me? I cannot run a block of code at a time because int hat case I will lose temp variables.
Note: Of course it is better not to write scripts in this way, but I found this and I would like to fix the problem.
In Sql Server Management Studio 2008 you can debug in a very similar manner to Visual Studio. Just set a break point on the line you want to debug and then click the debug button (alt-F5). This will start debugging from the first line. click the debug (play) button again and it will run to the line of code where you set your break point. Hope this helps.