1 year ago

#302198

test-img

Cam

When using OPENROWSET, how can I filter out non-numeric rows of a specific column?

I'm using OPENROWSET to import regular csv data files into a SQL table. Very occasionally one of the columns (which is supposed to be a SMALLINT) contains the value 'UNKNOWN', which obviously causes an error.

Assume that I cannot change the schema of our tables, and cannot stop the 'UNKNOWN' value from appearing in the files. How can I filter these rows out in the OPENROWSET query? I have tried inserting MAXERRORS=1000 but the file still errors.

sql-server

csv

tsql

openrowset

0 Answers

Your Answer

Accepted video resources