2
votes
1answer
196 views

Moving away from CmdExec steps in job without losing logging detail (SQL Server 2008)

My department currently relies heavily on CmdExec steps in SQL Server Jobs, called using a SQL Server Login. For example osql /e /n /S SERVER01 /U USER /P PA$$$ /d DATABASE_01 /i ...
4
votes
1answer
296 views

Raising an error with a system message_id in SQLCLR

If call CREATE DATABASE foo twice I get the error message: Msg 1801, Level 16, State 3, Line 1 Database 'dropme' already exists. Choose a different database name. The error message is listed in ...
4
votes
3answers
879 views

Write to Error Log

Using SQL Server 2008 R2: How can I write to the SQL Server Error Log? I have a ROLLBACK statement that I'd like to couple with a statement written to the error log for external monitoring. ...
5
votes
2answers
734 views

Error handling in container procedures

I'm aware of and use the techniques in this question. In my environment we have a lot of container procedures that call subprocedures, that may call other procedures, ad infinitum. For me ...
2
votes
2answers
705 views

Running a number of .sql files using SQLCMD

I'm trying to put together a batch file to run a large number of .sql files without doing so individually. So far I have: @echo off echo "Enter Server" set /p SERVER= echo "Enter Database" set /p ...
1
vote
1answer
3k views

Changed database context to 'MyDbName'

I am catching all errors on my Sql Server, I got errors: Changed database context to 'MyDbName'. Changed language setting to us_english. I haven't found any clear explanation of problem and ...
0
votes
1answer
432 views

Make SQL Server Agent retry failed script with Try/Catch

I have a script that has a try catch in it so that if it fails I can roll back the transaction. It runs on a job scheduled through SQL Server Agent. But when it fails SQL Server Agent does not see ...