T-SQL筆記52_去除decimal小數點後面轉字串時多餘的0
1 2 | declare @string varchar(20)= '0.0775000' Select LEFT(@string,LEN(@string)+1 - PATINDEX('%[1-Z]%',REVERSE(@string))) |
上一個版本會將10.00000變成1
用以下這版
declare @string varchar(20)= '10000.0102000'
Select LEFT(@string,LEN(@string)+1 - PATINDEX('%[1-Z.]%',REVERSE(@string)))
Ref:
https://stackoverflow.com/questions/2938296/remove-trailing-zeros-from-decimal-in-sql-server
https://stackoverflow.com/questions/46531742/remove-text-within-parenthesis-in-sql
https://dba.stackexchange.com/questions/185571/remove-dot-at-end-of-line-of-the-string-in-sqlserver
留言
張貼留言