UFN_PHONEFORMATCODE_GETFORMAT

This functions returns a phone format given the format code passed in.

Return

Return Type
nvarchar(20)

Parameters

Parameter Parameter Type Mode Description
@FORMATCODE tinyint IN

Definition

Copy


            CREATE function dbo.UFN_PHONEFORMATCODE_GETFORMAT
            (
                @FORMATCODE tinyint
            )
            returns nvarchar(20)
            with execute as caller
            as begin
                declare @PHONEFORMAT nvarchar(20) = '';

                select @PHONEFORMAT = 
                    case @FORMATCODE
                        when 0 then '<Unformatted>'
                        when 1 then '(###) ###-####'
                        when 2 then '(#####) ######'
                        when 3 then '(###) #### ####'
                        when 4 then '(####) ### ####'
                        when 5 then '(##) ### ####'
                        when 6 then '(##) #### ####'
                        when 7 then '#### ### ###'
                        when 8 then '#### ### ####'
                        when 9 then '### ### ###'
                        when 10 then '### ### ####'
                        when 11 then '(#) ##-###-####'
                    end

                return @PHONEFORMAT;
            end