Method for obtaining the execution time of SQL statements

Source: Internet
Author: User

Found online:

-- Before an SQL statement, add:
Declare   @ D   Datetime
Set   @ D = Getdate ()
-- SQL statement
-- Add the following after the SQL statement:
Select   [ Statement execution time (MS) ] = Datediff (MS, @ D , Getdate ())

The query results cannot be intuitively displayed in the query analyzer. You have improved the query results by yourself: -- Before an SQL statement, add:
Declare   @ D   Datetime
Set   @ D = Getdate ()
-- SQL statement
-- Add the following after the SQL statement:
Select   @ D   As   ' Start Time ' ,Getdate()  As   ' End Time ' , Datediff (MS, @ D ,Getdate()) As   ' Execution time '

However, this method cannot produce results for queries that consume a small amount of time. I don't know what other software and methods can be used to obtain the exact execution time of SQL statements.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.