BCP Utility With Additional “INSERT VALUES” Clause

15 pts.
Tags:
BCP Utility
I've nested 23 separate BCP commands into a single BAT file. Each BCP command pulls data from a separate text file and inserts the data into a single table. Here's the kicker, when inspecting the newly inserted rows in the table, I need to be able to associate each row with the BCP command that inserted it. Modifying the source data in the text files is not possible. Is there some way to tell the BCP command to insert a constant into an additional column in the table. Note that I AM using a format.xml file with the BCP insert. If needed, I'm willing to switch from BCP to BULK INSERT. Suggestions?

Answer Wiki

Thanks. We'll let you know when a new response is added.

BCP the data into a staging table, then add the additional value when moving the data from the staging table to the final table.

Neither BCP nor BULK INSERT will allow you to put an additional static value into the destination table.

DTS or SSIS should be able to do this for you.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Denny Cherry
    Check out my SQL Server blog "SQL Server with Mr Denny" for more SQL Server information.
    66,010 pointsBadges:
    report
  • Jdana
    Mrdenny, Great blog. I used sqlcmd. What a great little tool! I ended up running BCP, then sqlcmd UPDATE where I updated an empty column that acts as identifier for the previous BCP insert. J
    15 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following