I made this script to process batch .sql source files to define SP (as part of migration). It works fine but I can' catch any exception, when any source file is bad and given sp can not be created. I tried touse try/catch and looks like cmdshell doesn't care about result, even output for this file is different then for good files. do you know how else I can catch bad files ??
Thanks M
While @cc > @ccRun
Begin
set @ccRun = @ccRun + 1;
set @shellArg = (select 'sqlcmd -S '+ etc...+ @file....);
begin try
EXEC xp_cmdshell @shellArg -- to create sp
end try
begin catch -- try to catch bad files,??
select 'Error_____ for ' + @file
end catch
End