5

Another idea using Extended Events. Create an extended events session to catch errors CREATE EVENT SESSION [Track_Errors] ON SERVER ADD EVENT sqlserver.error_reported( ACTION(sqlserver.client_app_name,sqlserver.client_hostname,sqlserver.database_name,sqlserver.is_system,sqlserver.server_instance_name,sqlserver.server_principal_name,sqlserver.sql_text)) ...


5

When my stored procedures run other stored procedures, how can I find out which stored procedure's code generated the error? In your CATCH block, you can use ERROR_PROCEDURE() to get the name of the procedure or trigger where the error occurred. If you simply use THROW in your CATCH block in the inner procedures, then your outer procedure can access these ...


5

Use @@procid to get the currently executing routine and object_name() to convert the id to a name Hth


2

That behavior is expected and is described on the sp_describe_first_result_set doc under the Remarks section: For each control flow path, the first statement (if any) that returns a result set is determined by sp_describe_first_result_set. When multiple possible first statements are found in a batch, their results can differ in number of columns, column ...


1

We can get the number of connections active for each trunk/period/interval combination like so: WITH Numbers(val) AS ( SELECT 1 UNION ALL SELECT val + 1 FROM numbers WHERE val < 48 ) ,ConnectionPeriod AS ( SELECT period.period_start ,period.period_end ,@period as Period ,src.Trunk ,CASE WHEN ...


1

That should be simple: ALTER PROCEDURE myproc SET default_transaction_isolation = 'repeatable read'; The downside to that is that because of the limitations of transaction management inside procedures, you can no longer COMMIT or ROLLBACK inside such a procedure. If you need that, you could start the procedure body like this: COMMIT; -- otherwise you ...


Only top voted, non community-wiki answers of a minimum length are eligible