Home  >  Article  >  Database  >  去掉前面的0的sql语句(前导零,零前缀)

去掉前面的0的sql语句(前导零,零前缀)

WBOY
WBOYOriginal
2016-06-07 18:02:045233browse

一个列的格式是单引号后面跟着4位的数字,比如’0003,’0120,’4333,我要转换成3,120,4333这样的格式,就是去掉单引号和前导的0,用以下语句就可以。

原来sql还有个stuff的函数,很强悍。

一个列的格式是单引号后面跟着4位的数字,比如'0003,'0120,'4333,我要转换成3,120,4333这样的格式,就是去掉单引号和前导的0,用以下语句就可以。

SELECT stuff(substring([当前组织],2,4),1,patindex('%[^0]%',substring([当前组织],2,4))-1,''),人员编码

FROM dbo.orgusermap$

where 人员编码 is not null
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn