代码
CREATE
FUNCTION
[
dbo
]
.
[
FunIsInteger
]
(
@strs varchar ( 50 )
)
RETURNS bit
AS
BEGIN
declare @rb bit
if patindex ( ' %-% ' , @strs ) <> 0 set @strs = right ( @strs , len ( @strs ) - 1 )
if patindex ( ' %[^0-9]% ' , @strs ) = 0 and isnumeric ( @strs ) = 1
set @rb = 1
else
set @rb = 0
return @rb
END
(
@strs varchar ( 50 )
)
RETURNS bit
AS
BEGIN
declare @rb bit
if patindex ( ' %-% ' , @strs ) <> 0 set @strs = right ( @strs , len ( @strs ) - 1 )
if patindex ( ' %[^0-9]% ' , @strs ) = 0 and isnumeric ( @strs ) = 1
set @rb = 1
else
set @rb = 0
return @rb
END
这个函数可以判断是否为整数。