Unanswered: Trapping sqlcmd errors when executed from a job
I am running some scripts in files using sqlcmd via a SQL Server Agent job. If sqlcmd generates an error (for example if it is unable to connect) then the job fails. However, if the T-SQL within the script is invalid (syntax, name resolution etc etc) the job completes reporting success. If sqlcmd is invoked directly via the query window then no error is raised however there is a result set returned reporting the error.
Anyone know why and whether is it possible to get the error to be recognised by the job?
--The below is not actually valid SQL.
do SOME stuff, innit!