Sample Header Ad - 728x90

OPENROWSET Bulk insert Text File NULL Columns

3 votes
2 answers
554 views
I need to automate a weekly import of .txt log files into a SQL database. I have already created my table, format file and can get some of the data to work using OPENROWSET BULK, but the data from the log files is not consistent. The table has 10 columns 9 of which are populated from the log file, last 3 columns are all descriptions but the log file may only have a single description column populated (the max is always 3). In the image below the highlighted rows work because they have the valid 3 column worth of data separated by a comma. Is there a way to force BCP to always populate the 3 columns or mark them as NULL then move onto the next row? enter image description here
Asked by Stockburn (501 rep)
Jul 28, 2020, 06:45 AM
Last activity: Jan 20, 2025, 10:02 AM