user1151923
user1151923

Reputation: 1872

Show recently executed stored procedures, including parameters

This sql kindly provided by Microsoft lets me see the recently executed stored procedures, but not the values that were passed as parameters.

Where should I look for that information?

SELECT TOP 10 
    d.object_id, d.database_id, 
    OBJECT_NAME(object_id, database_id) 'proc name', 
    d.cached_time, d.last_execution_time, d.total_elapsed_time, 
    d.total_elapsed_time/d.execution_count AS [avg_elapsed_time],
    d.last_elapsed_time, d.execution_count
FROM 
    sys.dm_exec_procedure_stats AS d
ORDER BY 
    [total_worker_time] DESC;

Upvotes: 3

Views: 277

Answers (2)

Solomon Rutzky
Solomon Rutzky

Reputation: 48776

That information doesn't really exist anywhere (unless, as others have suggested, you store it yourself). However, you can see it by using SQL Profiler or Extended Events. With SQL Profiler, you need to choose the RPC:Completed and SQL:BatchCompleted events, and make sure that the TextData column is selected for both.

Upvotes: 2

Rawle
Rawle

Reputation: 199

Why not just have you stored procedure insert into someTable on the database.

Something like

INSERT INTO someTable (Value) 
SELECT @StoredProcedureInsertParamter

Upvotes: 1

Related Questions