Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-04-28 : 08:23:28
|
| Lee Broad writes "I have a table with 20 columns and several text files to import. All the text files have 20 column headings. My problem is that a couple of the text files have some rows (not all) that do not have the required number of tabs taking them up to the required number of columns. The tabs stop after the last column with data in. Whilst the file will import without a problem via Enterprise Manager/Import, BULK INSERT throws a 'String or binary data would be truncated.' error. Is there a way round this using BULK INSERT?" |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2002-04-30 : 03:51:15
|
| AFAIK, bulk insert is used for quickly loading data into a table without screwing around with conditions etc. Therefore it's fussy about the sort of data it's importing.You could write a bit of code that 'cleans' the file before import, but you'd be better off sticking to running a DTS task (easier to maintain for one thing). |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-04-30 : 13:49:53
|
| You *might* be able to use a format file to help BULK INSERT interpret the file, but I don't think it will really solve the problem. Check out "bcp" and "format files" in Books Online to see if they might help, but I think you should do as Timmy suggests and write some code to fix the file (or see if whoever is providing it to you can standardize the format) |
 |
|
|
|
|
|