March 3, 2022 at 9:18 pm
Hello everyone. Here is my situation:
I am currently attempting to utilize bcp to import a pipe delimited file into a SqlServer 2016 server and database. The table has more columns than the file does in anticipation of an upgrade in file formats to include these columns, but we also want backward compatibility for the the previous version. Does the number of columns in the file have to match the number of columns in the table? If it doesn't, what sort of switches or commands need to be used to prevent the carriage return from concatenating with the next row's first field and importing it into the extra columns in the table? I've been working on this most of the day and I'm going balder and grayer by the second. 🙂
Any help would be fabulous
March 3, 2022 at 9:58 pm
Basically you'll need to use a format file that maps the fields from your source file to the specific columns in the target table if the number/order of columns isn't exactly the same. This should get you the base 1 to 1 format file for your table for a comma delimited input. You'd need to modify that to match your file to the table.
bcp <table> format nul -f <format file name> -S <server> -T -d <database> -c -t ","
But if you want to avoid balding and grayness, try SSIS instead.
March 3, 2022 at 10:55 pm
Thanks for the quick reply. I'll give this a try and see how it does. Much appreciated. Personally not sure why we don't use SSIS on this, but that's out of my area. If I had anything to do with it, I would definitely do it 🙂
March 26, 2022 at 10:33 am
This was removed by the editor as SPAM
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply