I am running osql command that goes and grabs files from my folder and runs one script at a time and loops though all the files in that folder. Most of the files and simple inserts or creation of stored procedures.
Problem is that I want to exit out from osql if there is any error encountered while runing the script..
I am using following command
Cursor--
SELECT @cmdstr = 'osql -E -S ' + @servername + ' -d ' + @dbname + ' -n -i ' + @input_full_pat h -- ' >> ' + @outputfile
--show script processing
PRINT 'Processing script: ' + @scriptname + '..'
-- Cursor - go grab next file from folder
I tried
EXEC @errorstate=mas ter.dbo.xp_cmds hell @cmdstr
print @errorstate
IF @errorstate<>0
BEGIN
CLOSE crs_scripts
DEALLOCATE crs_scripts
RAISERROR('xp_c mdshell returned error while running script: %s', 15,3,@scriptnam e)
RETURN
END
but it only takes care of osql specific errors and not the actual script run time error..
Please help ...
Problem is that I want to exit out from osql if there is any error encountered while runing the script..
I am using following command
Cursor--
SELECT @cmdstr = 'osql -E -S ' + @servername + ' -d ' + @dbname + ' -n -i ' + @input_full_pat h -- ' >> ' + @outputfile
--show script processing
PRINT 'Processing script: ' + @scriptname + '..'
-- Cursor - go grab next file from folder
I tried
EXEC @errorstate=mas ter.dbo.xp_cmds hell @cmdstr
print @errorstate
IF @errorstate<>0
BEGIN
CLOSE crs_scripts
DEALLOCATE crs_scripts
RAISERROR('xp_c mdshell returned error while running script: %s', 15,3,@scriptnam e)
RETURN
END
but it only takes care of osql specific errors and not the actual script run time error..
Please help ...
Comment