By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,392 Members | 1,507 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,392 IT Pros & Developers. It's quick & easy.

SSN Format query

P: n/a
I have a query, here is a brief snipit:

SELECT Employment.PERSON_ID, Person.FIRST_NAME, Person.MIDDLE_NAME,
Person.LAST_NAME, Person.[SOCIALSECURITY#] AS SSN, ....

I want to return only the last 4 digits of the SSN. Can the below
snipit be incorporated into the above query?

something like: SET SSN = Right$(Replace(SSN,"-",""),5)

thanks!!!

May 10 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Parasyke wrote:
I have a query, here is a brief snipit:

SELECT Employment.PERSON_ID, Person.FIRST_NAME, Person.MIDDLE_NAME,
Person.LAST_NAME, Person.[SOCIALSECURITY#] AS SSN, ....

I want to return only the last 4 digits of the SSN. Can the below
snipit be incorporated into the above query?

something like: SET SSN = Right$(Replace(SSN,"-",""),5)

thanks!!!


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Don't use the SET, just use the expression in the SELECT clause:

... Right(Person.[SOCIALSECURITY#],4) AS SSN, ....

Since the SSN has 4 numerals as the last 4 digits you don't need to get
rid of the dash "-" before plucking those numerals from the SSN.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRGEc9YechKqOuFEgEQKXbwCfW78JlagWUWVVieoEqiwIIf BQuFQAniwp
LEXYO0C56REP6EM2ZSNQMgUo
=9laY
-----END PGP SIGNATURE-----
May 10 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.