I am providing search functionality in my website, when user searches a record then I want to display the time the query taken to get the results same as google does. When we search anything then google displays how much time it takes to get results?
For this I have declared a @start variable in my SP and finding the difference in the end, as below;
DECLARE @start_time DATETIME
SET @start_time = GETDATE()
-- my query
SELECT * FROM @search_temp_table
SELECT RTRIM(CAST(DATEDIFF(MS, @start_time, GETDATE()) AS CHAR(10))) AS 'TimeTaken'
Is there any other easy and fast way, or a single line of query with which we can find out the time a query taken to execute?
I'm using SQL Server 2005.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…