将数值转换为 Varchar [英] Convert Numeric value to Varchar

查看:49
本文介绍了将数值转换为 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.

例如:

select convert(varchar(10),StandardCost +'S')
from DimProduct where ProductKey = 212

这里 StandardCost 是一个数字字段,但是当我获取记录时出现错误.

here StandardCost is a numeric field, but when I fetch the record I get an error.

推荐答案

我觉得应该是

select convert(varchar(10),StandardCost) +'S' from DimProduct where ProductKey = 212

select cast(StandardCost as varchar(10)) + 'S' from DimProduct where ProductKey = 212

这篇关于将数值转换为 Varchar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆