输入banner图图片脚本导航/分类

Sql Server 判断字符串是否可以转数字

主要是在sql server的内置系统函数ISNUMERIC的基础上,将例外的“+”、“-”、“$”等进行也进行判断。

CREATE FUNCTION [dbo].[fn_IsNumberic]
(
@str nvarchar(max)
)
RETURNS int
AS
BEGIN
declare @res int
set @res=case when ISNUMERIC(isnull(@str,0))=1 then
case when PATINDEX(‘%[^0-9.]%‘,rtrim(ltrim(isnull(@str,0))))=0 then 1
end
end
return isnull(@res,0)
END

GO

Sql Server 判断字符串是否可以转数字

标签:ati   fun   tin   creat   dex   系统   cti   null   arc