Is there a way to automatically refresh the result of a query in the Microsoft SQL Server Management studio (SQL Server 2008 R2)?
有没有办法在Microsoft SQL Server Management工作室(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.
目前我正在调试一个自动插入和更新数据库中的数据的应用程序,我想跟踪进度,而不必在F5键上存放重物。
2 个解决方案
#1
41
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
它将运行查询5次,每次运行之间暂停10秒
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.
#2
7
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.
我唯一可以想到的就是SSMS中的那个,就是一个带有WAITFOR选项的循环。问题是您的输出查询窗口将只有多个结果集,每个结果集都在您的流程中,而不是之前的流程。
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).
在这种情况下,我通常建议构建一个从您的计算机本地运行的简单网页。构建它以进行查询,并将其设置为每个间隔(30-60-90秒)自动刷新。
But that would be outside SSMS.
但那将是SSMS之外的。
#1
41
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
它将运行查询5次,每次运行之间暂停10秒
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.
#2
7
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.
我唯一可以想到的就是SSMS中的那个,就是一个带有WAITFOR选项的循环。问题是您的输出查询窗口将只有多个结果集,每个结果集都在您的流程中,而不是之前的流程。
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).
在这种情况下,我通常建议构建一个从您的计算机本地运行的简单网页。构建它以进行查询,并将其设置为每个间隔(30-60-90秒)自动刷新。
But that would be outside SSMS.
但那将是SSMS之外的。