Solved Insert Into Error (1 Viewer)

doco

Power User
Local time
Today, 12:23
Joined
Feb 14, 2007
Messages
482
1629070957842.png

I am importing a flat file (*txt pipe delimited) into sql server. As you may see for column five (call_sign) nulls are not allowed. Yet I get this error when attempting to insert:
1629071125984.png


Any help would be appreciated.

TIA
doco
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:23
Joined
Oct 29, 2018
Messages
21,469
My guess is that the text file you're trying to import has missing data for that column. Have you double checked for that possibility?
 

doco

Power User
Local time
Today, 12:23
Joined
Feb 14, 2007
Messages
482
Yes, but its 2.38 million rows in a pipe delimited text file - a little busy. I'll check again. Thanks
 

plog

Banishment Pending
Local time
Today, 14:23
Joined
May 11, 2011
Messages
11,646
Yet I get this error when attempting to insert:

'Yet' is a weird term to start that sentence with. 'As expected' would be a better fit.

You showed us the schema where [call_sign] does not permit nulls, then you showed us an error you got when you tried to put a NULL value into [call_sign]. Seems pretty straight forward.

I would use the wizard to import the file into a new table (https://docs.microsoft.com/en-us/sq...import-flat-file-wizard?view=sql-server-ver15). Once imported you can verify issues and build a query around anything preventing the direct importation. THen you can turn that query into an INSERT INTO and move the data into the actual table you want that data in.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:23
Joined
Oct 29, 2018
Messages
21,469
Yes, but its 2.38 million rows in a pipe delimited text file - a little busy. I'll check again. Thanks
I was about to say the same thing. Basically, pre-import the data to a temp table without constraints, so you can easily examine the data using SELECT queries.
 

doco

Power User
Local time
Today, 12:23
Joined
Feb 14, 2007
Messages
482
'Yet' is a weird term to start that sentence with. 'As expected' would be a better fit.

You showed us the schema where [call_sign] does not permit nulls, then you showed us an error you got when you tried to put a NULL value into [call_sign]. Seems pretty straight forward.

I would use the wizard to import the file into a new table (https://docs.microsoft.com/en-us/sq...import-flat-file-wizard?view=sql-server-ver15). Once imported you can verify issues and build a query around anything preventing the direct importation. THen you can turn that query into an INSERT INTO and move the data into the actual table you want that data in.
From my perspective the NULL was not expected as the field should not be null. However, its an FCC dataset. They have the sloppiest data of anyone I've seen. A great deal of time is spent cleaning up their messes. Pretty indifferent folks there - so, no surprises here.

BTW, there was missing data.
Thanks
doco
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:23
Joined
Oct 29, 2018
Messages
21,469
From my perspective the NULL was not expected as the field should not be null. However, its an FCC dataset. They have the sloppiest data of anyone I've seen. A great deal of time is spent cleaning up their messes. Pretty indifferent folks there - so, no surprises here.

BTW, there was missing data.
Thanks
doco
Hi. Glad to hear you got it sorted out. Good luck!
 

Users who are viewing this thread

Top Bottom