September 25, 2008 at 3:36 am
I started working now with SQL server.
I am missing a statement I can stop execution of a script.
E.g., I am writing some longer statement also taking longer time. During that process, I want to run some short test SQL statements, but actually I do not want to change windows or so, just type it ahead and run - but I want the script to stop so the long running statements at the end are not executed.
The suggested :exit does not work in a Management Studio Query.
Any other suggestions?
Or how do you do it better?
I mean I like to have the Management studio around so I can see different things at once - but I do find it uncomfortable changing windows for every little bit.
September 25, 2008 at 3:42 am
Do you mean to say you want to debug to SP?
September 25, 2008 at 3:53 am
No : just typing in a query window and execute only first three statements.
later execute all (commenting the exit statement or whatever it is)
and then again only first three after modifying something.
Is that so uncommon?
I have found the raiseerror - but find that a little hard
September 25, 2008 at 5:06 am
On the other hand.. it is so common that probably no-one realized that this is what you were asking :-).
If you want to execute part of the code, not all that is in the window, highlight this part and then click on Execute. Execute runs entire contents of window only if nothing is selected. You don't need to comment part of the code.
September 25, 2008 at 5:56 am
Thank you very much, thats it.:)
September 25, 2008 at 6:52 am
I'm glad it helped :-).
Another possibility - in case that you need to run start and end of the code, skipping the middle part, you can use GOTO label:
select 'start'
GOTO the_end
select 'middle'
the_end:
select 'end'
This way, variables declared and assigned in the first part will still be available for the code when the "end" part is running.
Also, if you want to skip a block of rows from code, you can use /**/ comment
select 'start'
/* select 'middle1'
select 'middle2' */
select 'end'
However, this will not work if the code already contains some comments of the same type - /**/ comments can't be nested.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply