March 16, 2011 at 1:46 am
Hi,
i 'm having sp. it consits of update,select, insert query. i have executed this sp with parameter.
example: sp_name : exec abc '03/15/2011'
I just want to know, which query is executing in this sp.
i used to print ''.. but it shows the same output.. exec abc '03/15/2011' result only.
i don't want that result.
Could anyone knows, help me
Regards
Balaji G
March 16, 2011 at 4:59 am
You will need to either put "breaks" into the stored procedure or run the statements separately.
March 17, 2011 at 11:11 am
here's some code what I pinched from somewhere -
--How to isolate the current running commands in SQL Server. This query isolates the SQL in the batch
-- actually running at this point rather than the last command to execute
SELECT SDER.[session_id], SDER.[request_id],SDER.[statement_start_offset],
SDER.[statement_end_offset],
CASE
WHEN SDER.[statement_start_offset] > 0 THEN
--The start of the active command is not at the beginning of the full command text
CASE SDER.[statement_end_offset]
WHEN -1 THEN
--The end of the full command is also the end of the active statement
SUBSTRING(DEST.TEXT, (SDER.[statement_start_offset]/2) + 1, 2147483647)
ELSE
--The end of the active statement is not at the end of the full command
SUBSTRING(DEST.TEXT, (SDER.[statement_start_offset]/2) + 1, (SDER.[statement_end_offset] - SDER.[statement_start_offset])/2)
END
ELSE
--1st part of full command is running
CASE SDER.[statement_end_offset]
WHEN -1 THEN
--The end of the full command is also the end of the active statement
RTRIM(LTRIM(DEST.[text]))
ELSE
--The end of the active statement is not at the end of the full command
LEFT(DEST.TEXT, (SDER.[statement_end_offset]/2) +1)
END
END AS [executing statement],
DEST.[text] AS [full statement code]
FROM sys.[dm_exec_requests] SDER CROSS APPLY sys.[dm_exec_sql_text](SDER.[sql_handle]) DEST
WHERE SDER.session_id > 50
ORDER BY SDER.[session_id], SDER.[request_id]
---------------------------------------------------------------------
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply