首页 > 数据库技术 > 详细

查询sql语句所花时间

时间:2015-05-29 15:26:45      阅读:273      评论:0      收藏:0      [点我收藏+]
--1:下面这种是SQL Server中比较简单的查询SQL语句执行时间方法,通过查询前的时间和查询后的时间差来计算的:

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


--复制1个表到另外的表
1:insert into Table2 (a,c,d) select a,c,5 from Table1
2:select a,c  into table2 from Table1

查询sql语句所花时间

原文:http://www.cnblogs.com/hking911218/p/4538444.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!