BCP Error - Invalid Object Name

Last Post 30 Mar 2005 09:03 AM by nosepicker. 4 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
planktonplus
New Member
New Member

--
29 Mar 2005 01:09 PM
Has anybody developed a solution to the following...

Upon BCPing a table into a database, if the table name doesn't exist then the BCP command returns the following error: "SQLState = S0002, NativeError = 208", "Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name "TableName". "

I'm using the -e parameter and outputting to an error file, then checking the "SizeInBytes" column... if <> 0 an error has occured and am trapping that event... BUT the file not found error is not trapped in the output error file and I'm unable to code for it.

Any ideas?
nosepicker
New Member
New Member

--
29 Mar 2005 04:46 PM
Instead of using the -e parameter, try just redirecting the output to a file, like:

bcp database..tablename in c:\yourfile.txt -c -Uuserid -Ppassword -Sservername > c:\yourerrorfile.txt
planktonplus
New Member
New Member

--
29 Mar 2005 04:57 PM
Thanks for your response. Initial testing looks promising
planktonplus
New Member
New Member

--
29 Mar 2005 05:27 PM
Quote

Originally posted by: nosepicker
Instead of using the -e parameter, try just redirecting the output to a file, like:

bcp database..tablename in c:\yourfile.txt -c -Uuserid -Ppassword -Sservername > c:\yourerrorfile.txt


Sometimes I get so caught up in the problem I overlook the easy solution... Your response worked a treat, and I can interrogate the new output file and determine if there was an error based upon its contents. So thanks for your assistance.

What I SHOULD do is to check if the destination table exists BEFORE performing the BCP command

That would make a lot of sense wouldn't it.

Doh !
nosepicker
New Member
New Member

--
30 Mar 2005 09:03 AM
Yeah, I should've thought of mentioning that too. Doh!- Nuts!
You are not authorized to post a reply.

Acceptable Use Policy