I have a SQL Server 2000 database with a column of type VARCHAR (255). All data is either NULL or numeric, accurate to two precision points (for example, "11.85"). I tried to run the following T-SQL query but got the error "Error converting varchar to numeric data type"
SELECT CAST([MyColumn] AS DECIMAL)
FROM [MyTable];
I tried a more specific listing, which also failed.
SELECT CAST([MyColumn] AS DECIMAL(6,2))
FROM [MyTable];
I also tried the following to find out if any data is non-numeric and only the return values were NULL.
SELECT ISNUMERIC([MyColumn]), [MyColumn]
FROM [MyTable]
WHERE ISNUMERIC([MyColumn]) = 0;
I tried converting to other data types such as FLOAT and MONEY, but only MONEY was successful. So I tried the following:
SELECT CAST(CAST([MyColumn] AS MONEY) AS DECIMAL)
FROM [MyTable];
... . , ? , , DECIMAL?
!