Assuming i have a stored procedure (example as follows)
CREATE OR ALTER PROCEDURE test
AS
BEGIN
SELECT * FROM sys.tables;
WAITFOR DELAY '01:00'
SELECT * FROM sys.tables
END
GO;
and I have a c# invocation of a SQLCommand that runs a stored procedure as follows
using (var connection = new SqlConnection(connectionString)){
connection.Open();
using(var command = new SqlCommand("test", connection)){
command.CommandType = CommandType.StoredProcedure;
command.ExecuteNonQuery();
}
}
Is there a way for me to get at the underlying sql statement currently being executed within the stored procedure?
What I would like to get is the ability to log, "SELECT * FROM sys.tables", "WAITFOR DELAY '01:00'", etc.