SET STATISTICS TIME ON ...sql SET STATISTICS TIME off
我是看时间跟踪器跟踪sql的执行时间 Duration 列
不用输出运行时间?还是说这个代码执行完SQL语句就会输出运行时间?
如何得到SQL精确的执行时间 方法一:declare @d datetime set @d=getdate() -->查询语句 select [语句执行花费时间(毫秒)]=datediff(ms,@d,getdate())方法二:SET STATISTICS TIME ONSELECT * FROM SYSOBJECTS -->你的查询SET STATISTICS TIME OFF
CHECKPOINT GO DBCC FREEPROCCACHE GO DBCC DROPCLEANBUFFERS GO DBCC FREESYSTEMCACHE('ALL') ; GO SET Statistics IO ON GO SET Statistics TIME ON GO declare @b datetime,@e datetime set @b =getdate() select * from tbset @e =getdate() select datediff(ms,@b,@e) SET Statistics IO OFF GO SET Statistics TIME OFF GO
方法一:declare @d datetime set @d=getdate() -->查询语句 select [语句执行花费时间(毫秒)]=datediff(ms,@d,getdate())方法二:SET STATISTICS TIME ONSELECT * FROM SYSOBJECTS -->你的查询SET STATISTICS TIME OFF CHECKPOINT GO DBCC FREEPROCCACHE GO DBCC DROPCLEANBUFFERS GO DBCC FREESYSTEMCACHE('ALL') ; GO SET Statistics IO ON GO SET Statistics TIME ON GO declare @b datetime,@e datetime set @b =getdate() select * from tbset @e =getdate() select datediff(ms,@b,@e) SET Statistics IO OFF GO SET Statistics TIME OFF GO
SET STATISTICS TIME ON
...sql
SET STATISTICS TIME off
不用输出运行时间?还是说这个代码执行完SQL语句就会输出运行时间?
方法一:declare @d datetime
set @d=getdate()
-->查询语句
select [语句执行花费时间(毫秒)]=datediff(ms,@d,getdate())方法二:SET STATISTICS TIME ONSELECT * FROM SYSOBJECTS -->你的查询SET STATISTICS TIME OFF
-> 新建跟踪->连接服务器 -> 选择模板(TSQL_Duration) 点击运行,然后你可以看到运行语句的时间
了(Duration 列)
2005在-->性能工具-->SQL Server Profiler
GO
DBCC FREEPROCCACHE
GO
DBCC DROPCLEANBUFFERS
GO
DBCC FREESYSTEMCACHE('ALL') ;
GO
SET Statistics IO ON
GO
SET Statistics TIME ON
GO
declare @b datetime,@e datetime
set @b =getdate()
select * from tbset @e =getdate()
select datediff(ms,@b,@e)
SET Statistics IO OFF
GO
SET Statistics TIME OFF
GO
set @d=getdate()
-->查询语句
select [语句执行花费时间(毫秒)]=datediff(ms,@d,getdate())方法二:SET STATISTICS TIME ONSELECT * FROM SYSOBJECTS -->你的查询SET STATISTICS TIME OFF
CHECKPOINT
GO
DBCC FREEPROCCACHE
GO
DBCC DROPCLEANBUFFERS
GO
DBCC FREESYSTEMCACHE('ALL') ;
GO
SET Statistics IO ON
GO
SET Statistics TIME ON
GO
declare @b datetime,@e datetime
set @b =getdate()
select * from tbset @e =getdate()
select datediff(ms,@b,@e)
SET Statistics IO OFF
GO
SET Statistics TIME OFF
GO