• SQL Server如何查看SQL语句的执行时间


    在SQL Server数据库中,如何才能查看SQL语句的执行时间呢?本文将为您介绍查询方法,供您参考,希望对您能够有所帮助。

    下面这种是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

    作者:沐雪
    文章均系作者原创或翻译,如有错误不妥之处,欢迎各位批评指正。本文版权归作者和博客园共有,如需转载恳请注明。
    如果您觉得阅读这篇博客让你有所收获,请点击右下方【推荐】
    找一找教程网-随时随地学软件编程 http://www.zyiz.net/

  • 相关阅读:
    php 验证码
    扫描登录
    正则表达式
    liunx 搭建svn
    jq
    spl_autoload_register()函数
    php函数操作文件
    配置nginx支持TP框架
    Object-c 访问控制
    Obiective
  • 原文地址:https://www.cnblogs.com/puzi0315/p/2644839.html
Copyright © 2020-2023  润新知