'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.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source