Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Error Message Expand / Collapse
Author
Message
Posted Tuesday, October 9, 2007 3:08 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, November 14, 2012 7:26 PM
Points: 63, Visits: 119
Initially I coded Restore Database in a TRY CATCH BLOCK.

The ERROR_MESSAGE() is collecting/showing the "RESTORE DATABASE is terminating abnormally".


When I execute Restore Database command in managmenet studio I get these following messages.

Msg 3257, Level 16, State 1, Line 1
There is insufficient free space on disk volume 'D:\' to create the database. The database requires 73002319872 additional free bytes, while only 67640401920 bytes are available.
Msg 3119, Level 16, State 4, Line 1
Problems were identified while planning for the RESTORE statement. Previous messages provide details.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

How do I collect all the three messages in TSQL in CATCH BLOCK.

Thanks.


Post #408711
Posted Wednesday, October 10, 2007 6:37 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 5:48 AM
Points: 13,925, Visits: 28,319
The first two messages are lower level messages that are not a part of the TSQL statement, but are occurring at a lower level within the system. The CATCH statement is only able to catch the higher level message. See the example in BOL with the syntax error within a stored procedure.

----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server Query Performance Tuning
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #408954
Posted Thursday, May 13, 2010 1:40 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Saturday, July 12, 2014 8:58 PM
Points: 14, Visits: 165
I know this is an old post, but has this changed? I have not read anything on it. In most languages you have an Exception and an inner Exception. It would be very handle to have the inner exception in this case as I can make my script more fail-safe. Instead, I am not thinking about programming a service in .NET to handle what SQL scripting is not able to.

Any thought or new concepts?
Post #921595
Posted Monday, May 17, 2010 6:51 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 5:48 AM
Points: 13,925, Visits: 28,319
Basically if the error will cause a disconnect, SQL Server can't catch or handle the error, so the calling code will have to.

----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server Query Performance Tuning
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #922868
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse