Hi.
I am using the BCP command in my c# console application to transfer the data from table to a delimited text file.
The process works fine, but errors out at time due to data issues . I am trying to find , if there is a way to capture the row containing the error in a log file.
Below is the existing code:
public static void ExecuteProcess(string fileName, string Query, string servername, string dbinstance)
{
using (var process = new Process())
{
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.FileName = "BCP";
process.StartInfo.Arguments = "\"" + Query + " \" queryout " + "\"" + fileName.Trim() + "\"" + " -T -S " + servername + " -d " + dbinstance + " -b 500 -c -C 65001 -t~";
process.Start();
string outputString = process.StandardOutput.ReadToEnd();
string errorString = process.StandardError.ReadToEnd();
}
}
How to capture the error row from table ? Thanks