When trying to debug, I can run with F5 or F9 without problems. Everything is as expected, with correct output, but when I try to debug as script with F7 and step through the script, I cannot step through. I get a message noting, changing from code to script mode. It highlights line 1 (DECLARE @var1 varchar...) but nothing happens. I click F7 to step thorugh the code and nothing seems to move. Line 1 is no longer hightlighted, cursor stays in place. There are no messages. It does not even stop at breaks that may be set up. It seems as if it runs through the script completely.
So how do you step through line by line? How do you debug as script? How do you get out of script debug mode? CurrentlyI haveto create a procedure to debug and get out of script debug mode.
Script debug only occurs at batch level. That means you can only break and watch between GO statement in your script.
WORKAROUND:
The code bug icon is the yellow lightening bolt with red bug icon; the object must exist at server side to perform the debug. In this case you debug line by line with step into and F7.
The script debug icon green arrow and red bug, you can perform the debug on any script file but only at the at batch level. So if there is only one batch level, only the first DECLARE will be hit and debugging will finished without stepping through.
Sample: only one batch level
DECLARE @var1 varchar (255)
DECLARE @var2 varchar (255)
SET @var1 = Tony
SET @var2 = tony
IF @var1 = @var2
BEGIN
PRINT true
END
ELSE
PRINT false
Step-through sample: break and watch between GO statement in your script
DECLARE @var1 varchar (255)
DECLARE @var2 varchar (255)
SET @var1 = Tony
SET @var2 = tony
IF @var1 = @var2
BEGIN
PRINT true
END
ELSE
PRINT false
go
PRINT false
go
PRINT true
STATUS:
Enhancement request CR 43277 has been submitted to Development for consideration in a future release of Toad for SQL Server.