SQL Server中的格式编号

Jam*_*ara 0 sql-server

我想格式化SQL Server中的数字.在例子中,

SET @B = '123456'  
Run Code Online (Sandbox Code Playgroud)

转换成

@B = '1234.56'
Run Code Online (Sandbox Code Playgroud)

怎么做 ?

问候,

Din*_*del 5

只需将您的数字除以100即可获得结果.

update yourtable set B=B/100
Run Code Online (Sandbox Code Playgroud)

或者它看起来像你的B变量是varchar,你可以试试这个.

set @B=convert(varchar,cast(@B as decimal) / 100);
Run Code Online (Sandbox Code Playgroud)