Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to set ExitCode for SQL Job

How to set ExitCode for SQL Job

Scheduled Pinned Locked Moved Database
databasesql-serversysadminagentic-aihelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alex almeida
    wrote on last edited by
    #1

    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 belowtry { .... code Environment.ExitCode = 0; } catch(Exception e) { Environment.ExitCode = -1; process.Kill(); } finally { process.Close(); }

    D 1 Reply Last reply
    0
    • A alex almeida

      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 belowtry { .... code Environment.ExitCode = 0; } catch(Exception e) { Environment.ExitCode = -1; process.Kill(); } finally { process.Close(); }

      D Offline
      D Offline
      DerekFL
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups