Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
netwerkassist
Starting Member
13 Posts |
Posted - 2011-09-21 : 20:55:59
|
I have database refresh script, and want it to email me and halt the script when an error occurs on a specific step as shown below (network path not correct): raiserror('Step 1. Copy Production Backup file over to Sustainment SQL Server',1,1) with nowait DECLARE @ReturnCode INT SELECT @ReturnCode = 0IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback EXEC master..xp_cmdshell 'COPY \\server1\backup$\HR83PRD_Full_LiteSpeed.BAK \\server2\backup$\HR83PRD_Full_LiteSpeed.BAK' QuitWithRollback:declare @dbname varchar(500)declare @dest varchar(1000)declare @path varchar(512)declare @stt varchar (5000)declare @subject_str varchar(1000)declare @from_str varchar(500)declare @now datetimeEXEC master..usp_sendcdomail @From = 'server1@mail.ca', @To = 'user1@mail.ca', @Subject = 'The network path was not found', @Body = 'Check and validate Network path for Production backupfile' IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTIONEndSave:RETURN --However even if the network path is correct it still triggers the email and halts the script. Appreciate input as the best way to handle this. |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
netwerkassist
Starting Member
13 Posts |
|
|
|
|