sql statement to remove the leading 0 (leading zero, zero prefix)

sql also has a stuff function, which is very powerful.

The format of a column is a single quote followed by a 4-digit number, such as' 0003, '0120,' 4333. I want to convert to the format of 3,120,4333, which is to remove the single quotes and leading 0s, just use the following statement.

SELECT stuff (substring ([current organization], 2,4), 1, patindex ('% [^ 0]%', substring ([current organization], 2,4))-1, ''), personnel code

FROM dbo.orgusermap$

where personnel code is not null 

Guess you like

Origin www.cnblogs.com/yangdunqin/p/sqlstuff.html