当前位置:Gxlcms > 数据库问题 > 查询sql语句所花时间

查询sql语句所花时间

时间:2021-07-01 10:21:17 帮助过:7人阅读

--1:下面这种是SQL Server中比较简单的查询SQL语句执行时间方法,通过查询前的时间和查询后的时间差来计算的:
declare @begin_date datetimedeclare @end_date datetimeselect @begin_date = getdate()<这里写上你的语句...>select @end_date = getdate()select datediff(ms,@begin_date,@end_date) as ‘用时/毫秒‘ 
--2:下面这种方法比较全面,将执行每个语句时采取的步骤作为行集返回,通过层次结构树的形式展示出来
set statistics profile onset statistics io onset statistics time ongo<这里写上你的语句...>goset statistics profile offset statistics io offset statistics time off

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

查询sql语句所花时间

标签:

人气教程排行