Notice (8): file_put_contents(): Write of 274 bytes failed with errno=28 No space left on device [CORE/src/Log/Engine/FileLog.php, line 140]

Notice: file_put_contents() [function.file-put-contents]: Write of 1108 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): SplFileObject::fwrite() [<a href='https://secure.php.net/splfileobject.fwrite'>splfileobject.fwrite</a>]: Write of 284 bytes failed with errno=28 No space left on device [CORE/src/Cache/Engine/FileEngine.php, line 141]

Notice: file_put_contents() [function.file-put-contents]: Write of 2560 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): SplFileObject::fwrite() [<a href='https://secure.php.net/splfileobject.fwrite'>splfileobject.fwrite</a>]: Write of 5437 bytes failed with errno=28 No space left on device [CORE/src/Cache/Engine/FileEngine.php, line 141]

Notice: file_put_contents() [function.file-put-contents]: Write of 3153 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): unserialize() [<a href='https://secure.php.net/function.unserialize'>function.unserialize</a>]: Error at offset 12268 of 12277 bytes [APP/Controller/NewsController.php, line 5571]

Notice: file_put_contents() [function.file-put-contents]: Write of 2761 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): SplFileObject::fwrite() [<a href='https://secure.php.net/splfileobject.fwrite'>splfileobject.fwrite</a>]: Write of 822 bytes failed with errno=28 No space left on device [CORE/src/Cache/Engine/FileEngine.php, line 141]

Notice: file_put_contents() [function.file-put-contents]: Write of 3152 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (2): Undefined array key "nsort" [APP/Controller/NewsController.php, line 3613]

Notice: file_put_contents() [function.file-put-contents]: Write of 2075 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (2): Trying to access array offset on value of type null [APP/Controller/NewsController.php, line 3613]

Notice: file_put_contents() [function.file-put-contents]: Write of 2099 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (2): Undefined array key "nsort" [APP/Controller/NewsController.php, line 3613]

Notice: file_put_contents() [function.file-put-contents]: Write of 2075 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (2): Trying to access array offset on value of type null [APP/Controller/NewsController.php, line 3613]

Notice: file_put_contents() [function.file-put-contents]: Write of 2099 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
sql自定义百分比转换小数函数代码 - 站长搜索
首页 > 资讯列表 > 编程/数据库 >>

sql自定义百分比转换小数函数代码

Warning (2): Undefined array key "nsort" [ROOT/plugins/Kuhuang/templates/Websites/view.php, line 430]
Notice: file_put_contents() [function.file-put-contents]: Write of 2423 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (2): Trying to access array offset on value of type null [ROOT/plugins/Kuhuang/templates/Websites/view.php, line 430]

Notice: file_put_contents() [function.file-put-contents]: Write of 2447 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
">
Warning (2): Undefined array key "nsort" [ROOT/plugins/Kuhuang/templates/Websites/view.php, line 430]

Notice: file_put_contents() [function.file-put-contents]: Write of 2423 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Warning (2): Trying to access array offset on value of type null [ROOT/plugins/Kuhuang/templates/Websites/view.php, line 430]

Notice: file_put_contents() [function.file-put-contents]: Write of 2447 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
2022-09-23 20:26:28 转载来源: 网络整理/侵权必删

复制代码代码如下:--CAST和CONVERT函数PercentageDECLARE@decdecimal(5,3),@varvarchar(10),@hundecimal(5,1)set@dec=0.025set@hun=@dec*100set@var=cast(@hunasvarchar(20))+'%'select@var---小数转化为百分数函数GetPercentageString---涂聚文GeovinDuifexists(select*fromdbo

复制代码 代码如下:

--CAST 和 CONVERT 函数 Percentage
DECLARE @dec decimal(5,3), @var varchar(10),@hun decimal(5,1)
set @dec=0.025
set @hun=@dec*100
set @var=cast(@hun as varchar(20))+'%'
select @var

---小数转化为百分数函数 GetPercentageString
---涂聚文 Geovin Du
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetPercentageString]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[GetPercentageString]
GO
CREATE function GetPercentageString
(
@dec decimal(10,3)
)
returns varchar(20)
AS
BEGIN
DECLARE @var varchar(10),@hun decimal(10,1)
SET @hun=@dec*100
SET @var=cast(@hun as varchar(20))+'%'
RETURN @var
END
GO
--测试数据 涂聚文 Geovin Du
SELECT [dbo].[GetPercentageString] (0.05)
SELECT [dbo].[GetPercentageString] (0.25)
SELECT [dbo].[GetPercentageString] (1.25)

--1. 查询字符串中是否包含非数字字符
SELECT PATINDEX('%[^0-9]%', '1235X461')
SELECT PATINDEX('%[^0-9]%', '12350461')
--2. 查询字符串中是否包含数字字符
SELECT PATINDEX('%[0-9]%', 'SUYLLGoO')
SELECT PATINDEX('%[0-9]%', 'SUYLLG0O')


DECLARE @dec decimal(10,4), @var varchar(10),@hun decimal(10,4),@I INT,@K INT,@S VARCHAR(20)
SET @var='5.23%'
--SELECT @K=LEN(@var)
--SELECT @S=LEFT(@var,@K-1)
SELECT @S=RIGHT(@var,1)
--SELECT @S
SELECT @I=CHARINDEX('%',@S)
IF @I>0
BEGIN
SET @var=REPLACE(@var,'%','')
SET @hun=CAST(@var AS decimal(10,4))
SET @dec=@hun/100
SELECT @dec
END
ELSE
BEGIN
SELECT @dec=NULL --'无效数据'
END


--百分数转化为小数函数 GetPercentageNumber
---涂聚文 Geovin Du
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetPercentageNumber]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[GetPercentageNumber]
GO
CREATE function GetPercentageNumber
(
@var varchar(10)
)
returns decimal(10,4)
AS
BEGIN
DECLARE @dec decimal(10,4), @hun decimal(10,4),@I INT,@K INT,@S VARCHAR(20)
SELECT @S=RIGHT(@var,1)
--SELECT @S
SELECT @I=CHARINDEX('%',@S)
IF @I>0
BEGIN
SET @var=REPLACE(@var,'%','')
SET @hun=CAST(@var AS decimal(10,4))
SET @dec=@hun/100
--SELECT @dec
END
ELSE
BEGIN
SELECT @dec=NULL --'无效数据'
END
RETURN @dec
END
GO
--测试数据 涂聚文 Geovin Du
SELECT [dbo].[GetPercentageNumber] ('5.23%')
SELECT [dbo].[GetPercentageNumber] ('%0.23')

标签: sql 自定义 百分比 转换 小数 函数 代码


声明:本文内容来源自网络,文字、图片等素材版权属于原作者,平台转载素材出于传递更多信息,文章内容仅供参考与学习,切勿作为商业目的使用。如果侵害了您的合法权益,请您及时与我们联系,我们会在第一时间进行处理!我们尊重版权,也致力于保护版权,站搜网感谢您的分享!

站长搜索

http://www.adminso.com

Copyright @ 2007~2025 All Rights Reserved.

Powered By 站长搜索

打开手机扫描上面的二维码打开手机版


使用手机软件扫描微信二维码

关注我们可获取更多热点资讯

站长搜索目录系统技术支持