Convert Numeric value to Varchar

后端 未结 2 1725
没有蜡笔的小新
没有蜡笔的小新 2021-02-12 13:57

i m trying to fetch the record using append some alphabt in my numeric column. but i m getting error, i tried with cast and convert function.

for exmaple



        
相关标签:
2条回答
  • 2021-02-12 14:38

    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
    
    0 讨论(0)
  • 2021-02-12 14:46

    First convert the numeric value then add the 'S':

     select convert(varchar(10),StandardCost) +'S'
     from DimProduct where ProductKey = 212
    
    0 讨论(0)
提交回复
热议问题