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 SQL2005.