[SQL] SQL语句,存储过程执行时间
2009-10-07 11:06
375 查看
有时候想知道执行的SQL语句需要多长时间 ,这样可以比较不同语句的执行效率。
------------------------------------------------------------------------------------
在事件探查器中能看到执行SP,SQL所占用的时间等信息
------------------------------------------------------------------------------------ 适用于存储过程
declare @begin_date datetime
declare @end_date datetime
select @begin_date = getdate()
exec 存储过程
select @end_date = getdate()
select datediff(ms,@begin_date,@end_date) as '用时/毫秒'
------------------------------------------------------------------------------------
打开SQL Server的查询分析器。在下面语句两个go中间加入要执行的sql语句。
------------------------------------------------------------------------------------
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
------------------------------------------------------------------------------------
在事件探查器中能看到执行SP,SQL所占用的时间等信息
------------------------------------------------------------------------------------ 适用于存储过程
declare @begin_date datetime
declare @end_date datetime
select @begin_date = getdate()
exec 存储过程
select @end_date = getdate()
select datediff(ms,@begin_date,@end_date) as '用时/毫秒'
------------------------------------------------------------------------------------
打开SQL Server的查询分析器。在下面语句两个go中间加入要执行的sql语句。
------------------------------------------------------------------------------------
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
相关文章推荐
- SQL SERVER 统计SQL语句或存储过程执行时间
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(89)-EF执行SQL语句与存储过程
- SQL Server 第四堂课,创建存储过程。存储过程是一组编译在单个执行计划中的transact-SQL语句。存储过程相当于C#函数,可以允许模块化程序设计,允许更快执行如果某操作需要大量transct-SQL代码或需要重复执行,将在创建存储过程中对其进行分析和优化。
- 存储过程中执行参数SQL语句
- 存储过程————执行拼接的SQL语句的字符串
- oracle 解除 sql语句、存储过程在执行中造成的锁
- 转贴自微软MSDN:建议执行动态SQL时,使用sp_executesql 存储过程而不要使用EXECUTE 语句
- 在SQL SERVER中定时执行SQL语句,或者存储过程.
- 存储过程中用exec执行sql语句问题
- sqlserver 存储过程中拼接sql语句 动态执行
- 在SQL SERVER中定时执行SQL语句,或者存储过程
- MySql带参数的存储过程编写(动态执行SQL语句)
- SQLSERVER 存储过程里如何执行SQL语句
- 返回SQL执行时间的存储过程
- 执行字符串SQL语句--带有参数的存储过程以及 int类型的字符串变量注意事项
- MySql带参数的存储过程编写(动态执行SQL语句)
- sql存储过程中执行sql语句
- mysql存储过程执行动态sql语句并返回值
- 在SQL SERVER中定时执行SQL语句,或者存储过程
- oracle 存储过程执行可输入sql语句并返回结果集