With SQL Server 2012 I am importing text files into temporary tables using BULK INSERT:
BULK INSERT #temp
FROM 'filepath\mydata.txt'
WITH
(
FIRSTROW = 2,
FIELDTERMINATOR = '\t',
ROWTERMINATOR = '\n',
KEEPNULLS
)
The #temp tables I create vary in data type and include float, nvarchar, and datetime.
My problem is that my data has several ways of naming NULL values including DNE, #N/A, NA etc. The presence of these values in non-character columns leads to this kind of error when I try to run the above code:
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 393, column 1 (Id)
I am wondering whether there is a way to specify a set of values (DNE, #N/A, NA etc.) in the table to automatically be considered NULL upon import.