Reputation: 449
I'm trying 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.
Upvotes: 23
Views: 191494
Reputation: 2634
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
Upvotes: 41
Reputation: 20237
First convert the numeric value then add the 'S'
:
select convert(varchar(10),StandardCost) +'S'
from DimProduct where ProductKey = 212
Upvotes: 8