How to set ExitCode for SQL Job
-
Hello Everybody I developed a console app that imports CSVs files to DataBase. Well, I need that app runs each 2 min, then I used SQL Server Agent to create a job to do that. But when my app raise a exception, the job can't recognize this error and enter in continuous process (looping). So the job can't execute next schedule. When app runs successful, the ExitCode == 0. See code below
try { .... code Environment.ExitCode = 0; } catch(Exception e) { Environment.ExitCode = -1; process.Kill(); } finally { process.Close(); }
-
Hello Everybody I developed a console app that imports CSVs files to DataBase. Well, I need that app runs each 2 min, then I used SQL Server Agent to create a job to do that. But when my app raise a exception, the job can't recognize this error and enter in continuous process (looping). So the job can't execute next schedule. When app runs successful, the ExitCode == 0. See code below
try { .... code Environment.ExitCode = 0; } catch(Exception e) { Environment.ExitCode = -1; process.Kill(); } finally { process.Close(); }
Have you tried out SSIS. It's pretty simple to use and you can send rows from your csv file that cause insert errors to an error file. See http://www.mridey.com/blog/Lists/Posts/Post.aspx?List=321eab0d-e4d2-4523-914e-128a6688109f&ID=7