Skip to main content

Posts

Showing posts with the label ssn

Validate SSN using SQL UDF

Use the following code to validate Social Security Number (USA). The rules used for validation are based on SSA website, Wikipedia and HowStuffWorks.com. There may be more rules to the validation. If you find any, keep me posted! 'njoy Validating! SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Ankeet -- Create date: 6/19/2008 -- Description: Validates SSN -- ============================================= ALTER FUNCTION ValidateSSN ( @SSN varchar (11) ) RETURNS varchar (255) AS BEGIN /* USAGE: SELECT DBO.ValidateSSN(777992322) BASED ON: http://people.howstuffworks.com/social-security-number2.htm http://en.wikipedia.org/wiki/Social_Security_number http://www.socialsecurity.gov/employer/stateweb.htm http://en.wikipedia.org/wiki/Individual_Taxpayer_Identification_Number The Administration publishes the last group number used for each area number.[17]. Since group numbers are allocated in a regular (if unusual) pattern, it i...