October 15, 2013 at 2:46 am
Hi,
is there a way via SSIS to create a table to match a file's headers (which can change), and then load that data into the table? I've been looking at BCP, batch load, & script task but can't find the best way.
October 15, 2013 at 2:52 am
g_demetriou (10/15/2013)
Hi,is there a way via SSIS to create a table to match a file's headers (which can change), and then load that data into the table? I've been looking at BCP, batch load, & script task but can't find the best way.
Nothing easy. So you want a new table every time? What would it be called? How would the column data types be determined?
October 15, 2013 at 2:57 am
You'll need to read the first line of the file (easiest way is a script task), get the individual column names and create a dynamic CREATE TABLE statement using those columns. The easiest method is to give every column a fixed data type, such as varchar(250) NULL.
After the table is created, you can use bcp or BULK INSERT to import the flat file into the table.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
October 15, 2013 at 4:43 am
Thanks. I'll give that a go
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy