Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-07 18:02:04
Original
5231 people have browsed it

一个列的格式是单引号后面跟着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
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!