Trying to run lines on a timer One of the things I need to do on my job is run lines of SQL code.  I need to do each line individually.  Which involves highlighting one line, executing it, then doing the next.  Sometimes it is up to 50 lines, so I'm trying to find an easier way.

Not giving specifics, basically each line reads

UPDATE que SET status = 0 WHERE doc = '001'; EXECUTE [things] '001'

UPDATE que SET status = 0 WHERE doc = '002'; EXECUTE [things] '002'

UPDATE que SET status = 0 WHERE doc = '003'; EXECUTE [things] '003'


etc etc

Is there some kind of command that will do each line one after another?  preferably with like a 10 second timer inbetween?
You can add WAITFOR DELAY between executions. 

UPDATE que SET status = 0 WHERE doc = '001'; EXECUTE [things] '001';
WAITFOR DELAY '00:00:10';
UPDATE que SET status = 0 WHERE doc = '002'; EXECUTE [things] '002';
WAITFOR DELAY '00:00:10';
UPDATE que SET status = 0 WHERE doc = '003'; EXECUTE [things] '003';
WAITFOR DELAY '00:00:10';


Might be a good idea to add some (error) logging as to know where it failed if an error occured.

If you don't want to write 50 extra lines, you could use search and replace in ssms (CTRL+F) and replace 'UPDATE' with 'WAITFOR DELAY '00:00:10';  UPDATE'



Make sure you are on current document and then press replace all:



Result: