I have a C# console app, which call sqlcmd utiltiy, and get the exit code as -100.
Code looks like below;
private int RunSP()
{
int exitCode = 1;
Log.Log("Creating Stored Procedure: " + Config.ExternalSPname);
Process p = new Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = string.Format("sqlcmd -S {0} -d {1} -Q \"EXIT(exec {2} @ MainListID=N'{3}', @ TempListID =N'{4}')\"", Config.ExternalSPserver, Config.ExternalSPdb, Config.ExternalSPname, Config.ExternalSPmainlist, Config.ExternalSPtemplist);
Log.Log("SP command: " + p.StartInfo.FileName);
p.Start();
p.WaitForExit();
exitCode = p.ExitCode;
p.Close();
return exitCode;
}
The stored procedure is written as return exit code 1 when it's worked, 0 when it's failed.
I wonder if sqlmod can return -100 in certain cases.
Thanks