-2
votes
0answers
29 views

is there any way to retrieve last error message [closed]

is there a way to obtain the last error message for SQL Server 2012? I'm just wanting a way to get the last generated error message. Update I am looking for the last error generated in T-SQL. ...
2
votes
2answers
3k views

How to break SQL script execution

I am working on sql script and I am having a requirement of stop continuing the script if some conditions are not satisfied. When I Google it, I found the RaisError with 20 severity level will ...
2
votes
3answers
506 views

Backups script completes, but doesn't back up all dbs

I'm running sql server 2005 and I've made a simple backup script that backs up all the databases on one server. The script always succeeds, but when I go to check the log or the files, I see it has ...
1
vote
1answer
163 views

How to suppress an informational raiserror message

I have a setup script that calls sp_configure a few times to set up some system variables, it works fine but I have a few of the following statement Configuration option '%ls' changed from %ld to ...
0
votes
3answers
2k views

What is ERROR_STATE() in SQL Server and how it can be used?

I read that ERROR_STATE() can help to distinguish between different states/locations in the source code where same type of error can occur. But it is not really clear to me that how it can be useful. ...
3
votes
1answer
2k views

Finding exact statement causing error 3930

Lately I've been seeing errors in the SQL Server Log. Code:3930 Description:"The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the ...
4
votes
1answer
329 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 ...
2
votes
0answers
133 views

CREATE ASSEMBLY - EXCEPTION_ACCESS_VIOLATION

I am trying to create an assembly on my SQL Server 2005 server. Here is what I am using: CREATE ASSEMBLY [SQLCLRTest] AUTHORIZATION [dbo] FROM 'path\to\my\file.dll' WITH PERMISSION_SET = ...
4
votes
3answers
1k 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. ...
3
votes
3answers
4k views

How to log error details when using using try/catch for dynamic SQL backup commands

When issuing a backup command within a stored procedure that uses a try catch and dynamic sql, the error messages are very general when compared to running the backup command directly. Try/Catch ...
3
votes
1answer
329 views

tds: unable connect to SQL Server using servername specified in freetds.conf file

I am using freetds to connect to SQL Server from ubuntu. First, the SQL Server is running at port 1433 currently. I can telnet it. The following command also works. I can query table data using it, ...
5
votes
2answers
800 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 ...
0
votes
1answer
457 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 ...
2
votes
2answers
2k views

Query data from multiple linked remote databases

Using SQL Server 2005 databases and SQL Server Management Studio 2008, I need to query a single value from each of n linked databases at a regular interval. The servers are physically remote and I can ...