I have a weird problem.
In my query I select 5 columns which two of them are nvarchar
in the form of numeric (only contains number and precision point), and other three are uniqueIdentifier
and nvarchar
.
I want to cast these two columns to Float
in my select statement but I'm getting an error
Cannot cast nvarchar to float.
I checked the format of all these values many many times. Trust me, they are fine.
But when I just select these two columns and cast them to float the query runs successfully.
I appreciate any help on this subject.
I can paste the query here too. but the whole query is more then 100 lines and this will be frustrating to write and read!
select cast(x as float) from yourTable
? If that fails for either column, you know atleast one value is not compatible with that cast. Then tryselect top 100 x from yourTable order by x asc
and thendesc
; often the problem values are at the extremes. - MatBailie