在SQLServer上查看SQL语句的执行时间的方法

查看SQL语句在SQL Server上的执行时间,方便大家监控语句的性能。写出更好的代码。
1:下面这种是比较简单的查询方法,通过查询前的时间和查询后的时间差来计算的 
 

declare @begin_date datetime 
declare @end_date datetime 
select @begin_date = getdate() 
<这里写上你的语句...> 
select @end_date = getdate() 
select datediff(ms,@begin_date,@end_date) as '用时/毫秒' 


2:下面这种方法比较全面,将执行每个语句时采取的步骤作为行集返回,通过层次结构树的形式展示出来 
 

set statistics profile on 
set statistics io on 
set statistics time on 
go 
<这里写上你的语句...> 
go 
set statistics profile off 
set statistics io off 
set statistics time off

转载于:https://www.cnblogs.com/lichunlin/p/3673331.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值