I've got this tab-delimited flat file with fifty columns and two million rows. I am trying to import it into Sql Server 2017 Express. (I first tried working with it in Excel... hopeless.)
I see two import paths available: SqlServer Management Studio's Import Flat File command, and the Import and Export Data wizard. Both fail, but in different ways.
With SSMS, it seems to do a very good job of parsing the file and guessing the column types, but it bases the lengths on only the first few hundred rows. One column is long text, so I've tried setting it to nvarchar(4000) or nvarchar(max) or ntext. A few others I knew might be longer than the default guessed length of 50 so I bumped up the sizes. But when I run the import, it says that some column would be truncated or otherwise fail to convert, and it refuses to say which column is the one having trouble.
With the import wizard, on the other hand, it doesn't guess column types at all, and I have to manually set the ones I know. And thankfully, it has a setting that allows you to tell it per column whether to fail on conversion errors or ignore them. But it ignores this setting -- it always fails no matter how you set the tolerance, per column or globally.
The good part is that it does identify a column name where it failed, namely the long text column. But as best I have been able to measure it, there's nothing in it which should have failed. I don't think any value is over 4000 characters (the longest I've located is 2027) and I'm pretty sure the character set is pure ascii-7. In fact, it's been forced to all uppercase.
I also tried importing from the abortive Excel sheet I made. This was thwarted because only the 32 bit importer could see Excel, and only the 64 bit one could see my database instance.
How can I get one or the other of these to allow the import to complete?