Page 1 of 1

MS SQL script - how to check the error messsage?

Posted: Mon Jan 05, 2009 6:18 am
by Bar_BQ
Hi,


I'm just wondering if there is any possibility to check the error message that comes from MS SQL Server during script run. I'm trying to restore database backup file using SQL Server command:


RESTORE DATABASE [$DATABASE_RESTORE_NAME$] FROM DISK = N'$SELECTED_BAK_FILE$' WITH FILE = 1, NOUNLOAD, STATS = 10
GO

For some reason script works fine only sometimes, mostly there's an error. Does any possibility exists to check the error message?

Thanks,
BarBQ

Posted: Tue Jan 06, 2009 11:25 pm
by drewau
I can't seem to work out how to do this either.
I can get a SUCCESS/ERROR response in "Return result in variable" variable, but I would like to get a meaningful error message from RAISERROR.

Example of one of the scripts I'm running:

Code: Select all

EXEC('IF SERVERPROPERTY(''collation'') <> ''SQL_Latin1_General_CP1_CI_AS'' 
    RAISERROR(''SQL ErrorID: 235E86A3-2DC6-4D0F-B892-CB8F8E47AE29 
    Message: Invalid SQL Collation for install'', 16, 127) with nowait')
Do I need to write a custom plug in to do this?

Posted: Wed Jan 07, 2009 2:49 am
by ulrichard
I would also be interested in that feature. It would make debugging a lot easier.

Rgds
Richard

Posted: Wed Jan 07, 2009 3:50 am
by Bar_BQ
Receiving only message SUCCESS or ERROR is definitely not enough. Debugging won't help that much.

I'm finding that InstallAware makes some difficult things easy, but some easy things makes difficult...

Posted: Wed Jan 07, 2009 8:57 am
by CandiceJones
We'd like to add this feature. Please contact me privately if you would like to participate in testing a new version of the plugin which has this implementation in place.

Posted: Wed Jan 07, 2009 10:44 am
by Bar_BQ
thank you, that's very polite of you :)