Tue
Sep 19
2006

Removing double.NaN from a SQL table

SQL Server’s float datatype does not support the double.NaN value. SQL and T-SQL will prevent these values from entering the database, but ADO.Net does not. Query Analyzer will stop displaying additional results once it hits a NaN value. Enterprise manager will display -1.#IND. Normal queries on this value will result in errors so it is difficult to remove them. The solution: convert to a string first.

UPDATE mytable
SET floatColumn = NULL
WHERE cast(floatColumn AS varchar(100)) = '-1.#IND'

Leave a reply

© 2009 Brian Low. All rights reserved.