UFN_ACCOUNTCODE_ISVALIDINT

Determines if the given account code string is a valid non-negative integer.

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@CODE nvarchar(10) IN

Definition

Copy


create function dbo.UFN_ACCOUNTCODE_ISVALIDINT(@CODE nvarchar(10))
returns bit
with execute as caller
begin
    declare @VALID bit
    set @VALID = case
        when isnumeric(@CODE) = 0 then 0
        when @CODE like '%[^0-9]%' then 0
        when cast(@CODE as numeric(38,0))
            not between 0. and 2147483647. then 0
        else 1
    end
    return @VALID
end