I need to create a unique identifer from the values selected from 4 different fields. For example, I will query a db for a first name (pfname), a DOB (DOB), a gender (sex) and a Social security # (ssno).
Select pfname, dob, sex, ssno
from client
OK...I need:
the first 3 leters of the Pfname: 'nnn'
the entire dob in 'YYYYMMDD' format
the gender: 'm' or 'f'
the last 4 digits of ssno: '3958'
for a unique identifer that looks like: 'nnnyyyymmddm3958'
The example I have to work from
case when len(clm.pfname) >=3 then left(pfname,3)
else left(pfname,2) + '/' end
+ convert(varchar(12),clm.DOB,112)
+ clm.SEX
+ right(clm.GID,4),-- as [4], -- Unique Identifier
It uses a case, len, left, right and convert statements...which I don't really any experience with at this point in my professional development. So I would like some wisedom, if anyone would like to educate me and show me how to do this. I will add it to my bag of tricks for future use. Thanks ahead of time.
Bergg
Select pfname, dob, sex, ssno
from client
OK...I need:
the first 3 leters of the Pfname: 'nnn'
the entire dob in 'YYYYMMDD' format
the gender: 'm' or 'f'
the last 4 digits of ssno: '3958'
for a unique identifer that looks like: 'nnnyyyymmddm3958'
The example I have to work from
case when len(clm.pfname) >=3 then left(pfname,3)
else left(pfname,2) + '/' end
+ convert(varchar(12),clm.DOB,112)
+ clm.SEX
+ right(clm.GID,4),-- as [4], -- Unique Identifier
It uses a case, len, left, right and convert statements...which I don't really any experience with at this point in my professional development. So I would like some wisedom, if anyone would like to educate me and show me how to do this. I will add it to my bag of tricks for future use. Thanks ahead of time.
Bergg