I want to get transaction execute time in SQL Server 2008 R2 i want to get this time programmatically and save it in a table . How can do it?
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
Try executing "SET STATISTICS TIME ON;" on your connection before executing your transaction.
Save the time before and after the query and to calculate the difference, something like this:
JohnC is right and that is probably what you want.
But depending on your exact needs, there are other options. For one, SSMS tells you the amount of time, at least to the second, passed in the lower right cornor when you execute a query.
And of course you use getdate() to get the time from SQL Server immediately before and immediately after the execution and find the difference.
For repeated testing of large numbers of queries, you could also build a test harness in some other language like python with a library like timeit.