Home > Database > Mysql Tutorial > SQL Server中Money转Decimal

SQL Server中Money转Decimal

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 14:55:15
Original
2463 people have browsed it

SQL Server中Money转Decimal SQL Server DECLARE @int_digits SMALLINT,@digits SMALLINT,@total_digits SMALLINT,@sqlstr NVARCHAR(100)DECLARE @input MONEYDECLARE @f FLOATSET @input=234214.4434SET @int_digits=floor(log10(@input))+1SET @f=@input-fl

SQL Server中Money转Decimal SQL Server
DECLARE @int_digits SMALLINT,@digits SMALLINT,@total_digits SMALLINT,@sqlstr NVARCHAR(100)
DECLARE @input MONEY
DECLARE @f FLOAT
SET @input=234214.4434
SET @int_digits=floor(log10(@input))+1
SET @f=@input-floor(@input)
SELECT @digits=case LEN(CAST(@f AS VARCHAR))-2
WHEN -1 THEN 2
WHEN 1 THEN 2
WHEN 2 THEN 2
WHEN 3 THEN 3
ELSE 4
END
SET @total_digits=@int_digits+1+@digits
SET @sqlstr=N'SELECT CAST('+STR(@input,@total_digits,@total_digits)+' AS DECIMAL('+STR(@total_digits)+N','+STR(@digits)+N'))'
exec sp_executesql @sqlstr
Copy after login
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