1
Vote

Create function fn_iszip

description

Please create the function tsql.fn_iszip, tsql UDF function the determines if input parameter is a valid zip, should return 5 for Zip 5, 9 for valid zip 5+4, and 0 for invalid zip format.
 
Attached is the function template and help document , please send back both for the function to be included in the next release.

file attachments

comments

adudau wrote Sep 24, 2012 at 2:07 PM

Once code and help are returned I'll review them.

wrote Sep 25, 2012 at 12:54 PM

sharmaanurag wrote Sep 25, 2012 at 12:55 PM

i add some sample line of code for zip validate which only retun true false

--this is my test code --begin code
                                            declare @var int
                                            set @var = 8768787
                                            select @var =  LEN(@var)
                                            if @var = 5
                                            print 'true';
                                            else
                                            print 'false'
                                            --end code

adudau wrote Sep 25, 2012 at 1:04 PM

It is a good start, make sure you read the description of this task carefully, the function need to return INT not boolean, moreover it should check if the @zip parameters is numeric or is numeric plus "-" as in 02134-6784 zip code, any other nonnumeric characters would equal to invalid zip code triggering the function to return 0. Thanks

wrote Sep 26, 2012 at 12:33 PM

sharmaanurag wrote Sep 26, 2012 at 12:33 PM

i attaching a new code

wrote Feb 13, 2013 at 10:43 PM