Automatically refresh a query in ms sql server management studio?
Is there a way to automatically refresh the result of a query in the Microsoft SQL Server Management stud开发者_运维问答io (SQL Server 2008 R2)?
Currently i'm debugging an application which automatically inserts and updates data in a database and I'd like to track the progress without having to deposit a heavy object on the F5 key.
try this:
SELECT GETDATE() --your query to run
raiserror('',0,1) with nowait --to flush the buffer
waitfor delay '00:00:10' --pause for 10 seconds
GO 5 --loop 5 times
it will run the query 5 times, pausing for 10 seconds between each run
output:
Beginning execution loop
-----------------------
2011-03-25 11:03:57.640
(1 row(s) affected)
-----------------------
2011-03-25 11:04:07.640
(1 row(s) affected)
-----------------------
2011-03-25 11:04:17.640
(1 row(s) affected)
-----------------------
2011-03-25 11:04:27.640
(1 row(s) affected)
-----------------------
2011-03-25 11:04:37.640
(1 row(s) affected)
Batch execution completed 5 times.
The only thing I can think of that would do that enitrely from SSMS would be a loop with a WAITFOR option. The problem is your output query window will simply have multiple result sets, each one later in your process than the one before it.
In this situation I usually suggest building a simple web page that runs from locally on your machine. Build it to take a query, and set it to auto-refresh every interval (30-60-90 seconds).
But that would be outside SSMS.
精彩评论