sql_language thread: SUBSTRING question & syntax question - Please HELP.
I am having to access two different SQL servers where two databases reside
on one server and the other database on the other. I am enclosing the
code I am using whereby I have two questions (FIRST THE CODE):
SELECT physn.enterprsphysnid, physn.birthdate, physn.busncellulrphnnum,
physn.degreecode, physn.emailaddrtext, physn.ethnctydescr,
physn.firstname, physn.lastname, physn.mailaddr1text, physn.mailaddr2text,
physn.mailcityname, physn.mailstatecode,
physn.zipcode, physn.maritalstatuscode, physn.middlename,
physn.namesuffxtext, physn.pagrphnnum, physn.primaryofcaddr1text,
physn.primaryofcaddr2text, physn.primaryofccityname,
physn.primaryofccountyname, physn.primaryofcfaxnum,
physn.primaryofcphnnum,
physn.primaryofcstatecode, physn.primaryofczipcode, physn.sexcode,
physn.specltydescr, physn.ssnum, physn.subspecltydescr,
physn.texasstatelicnum, pssdb3.caregate.hcin_user.helpdesk_clientid,
pssdb3.caregate.hcin_user.username,
pssdb3.pss_customer_services.profile.clientid,
substring([pssdb3.pss_customer_services.profile.social_security],1,3) +
([pssdb3.pss_customer_services.profile.social_security],5,2) +
([pssdb3.pss_customer_services.profile.social_security],8,4)
FROM physn INNER JOIN pssdb3.pss_customer_services.profile
ON physn.ssnum = pssdb3.pss_customer_services.profile.ssn
LEFT OUTER JOIN pssdb3.caregate.hcin_user
ON pssdb3.pss_customer_services.profile.clientid
pssdb3.caregate.hcin_user.helpdesk_clientid
WHERE physn.ssnum = 'xxxxxxxxx'
a. Is the syntax ok for the SQL Server name.Database.Table.Field for each
machine?
b. I am having problems with the SUBSTRING function whereby I am trying
to concatenate the social_security field of one of the tables by removing
the (-)'s so that I can join to the other social security field in the
other table on the other machine. I am getting the following error:
Server: Msg 170, Level 15, State 1, Line 8
Line 8: Incorrect syntax near ','.
This error message starts at the substring line. Thanks for any help
anyone can give me.