Convert Numeric value to Varchar
I'm trying 开发者_Python百科to fetch the records and append some letters to my numeric column, but I'm getting an error. I tried with cast and convert function.
For example:
select convert(varchar(10),StandardCost +'S')
from DimProduct where ProductKey = 212
here StandardCost
is a numeric field, but when I fetch the record I get an error.
i think it should be
select convert(varchar(10),StandardCost) +'S' from DimProduct where ProductKey = 212
or
select cast(StandardCost as varchar(10)) + 'S' from DimProduct where ProductKey = 212
First convert the numeric value then add the 'S'
:
select convert(varchar(10),StandardCost) +'S'
from DimProduct where ProductKey = 212
精彩评论