I have a table already stored in sql server with all the columns and the data type of the columns. I am now trying to import a txt file into sql server. But since all the fields are already in the string format, it is not able to import the data into the server. Is there any way to change the format of the datatype within the txt file to match that of the table within the sql server? The number of columns are 150 to import
1 Answer
You may need to look into creating a SSIS package and adding the data conversion tool to cast/convert the data being imported into the correct datatype.
3 Comments
dklingman
The other option is to use the import wizard that allows you to change the datatype coming in. However, this might not give you enough flexibility that you need.
codemacha
dklingman, the problem with the import wizard is it still gives me a lot of errors and I have to do this for about 10 txt files. Some are data type conversion errors. Hence to use the import wizard and change 150 variables every time is a little bit painful
dklingman
That's what I figured and why I would suggest going the route of the SSIS package to do this.