I am importing a file into SQL Server using BCP utility in Perl program.
In the file which I am importing, there is a wrong date format so the Import process fails with following error:
SQLState = 22008, NativeError = 0
Error = [Microsoft][SQL Server Native Client 10.0]Invalid date format
I am executing the bcp command as follows in my perl program.
my $myBcp = "bcp.exe" <table name> in <temp file path> -f<format file> -m 1 -h "FIRE_TRIGGERS" -o<log file path>
my $myResult = system($myBcp);
When I print $myResult it gives me ‘0’. Since there is an “Invalid date format” error, it should return me a error code.
Can anyone let me know how to catch Invalid Date Format error in my perl program?
Thanks
You should redirect STDERR to STDOUT by
2>&1as follows: