Search code examples
sqlsql-server-2005

Convert Numeric value to Varchar


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.


Solution

  • 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