March 8, 2012 at 4:11 pm
Hi,
I have the following in SP
INSERT INTO @TEMPTABLE(TAG_NAME,TAG_DATA)
SELECT TAG_NAME = 'CUST_CLIENTNAME', TAG_DATA = (SELECT C.FNAME + CASE WHEN C.MNAME IS NULL THEN '' ELSE ' ' + C.MNAME END + ' ' + C.LNAME
FROM CLIENT C (NOLOCK)
WHERE C.OID = @CLIENT_OID);
I want to add an if statement where the tagdata would be
TAG_DATA = (SELECT A.FNAME + CASE WHEN A.MNAME IS NULL THEN '' ELSE ' ' + A.MNAME END + ' ' + A.LNAME FROM ALIAS A (NOLOCK)
INNER JOIN CLIENT_TO_ALIAS_COLLECTION AC (NOLOCK) ON AC.OID_LINK = A.OID
INNER JOIN ALIAS_TYPE AT (NOLOCK) ON AT.OID = A.ALIAS_TYPE_MONIKER
WHERE AT.ABBRNAME = 'Secure Client'
And AC.OID=@CLIENT_OID
AND A.EXPDATE IS NULL);
IF AT.ABBRNAME = 'Secure Client'
March 8, 2012 at 4:21 pm
Confused I am what you are asking.
March 8, 2012 at 4:25 pm
sorry....
So I have the following to add client name
with tage_name = 'CUST_CLIENTNAME'
INSERT INTO @TEMPTABLE(TAG_NAME,TAG_DATA)
SELECT TAG_NAME = 'CUST_CLIENTNAME', TAG_DATA = (SELECT C.FNAME + CASE WHEN C.MNAME IS NULL THEN '' ELSE ' ' + C.MNAME END + ' ' + C.LNAME
FROM CLIENT C (NOLOCK)
WHERE C.OID = @CLIENT_OID);
if AT.ABBRNAME = 'Secure Client'
then I Want TAG-DATA for TAG_NAME 'CUST_CLIENTNAME" to do the following
TAG_DATA = (SELECT A.FNAME + CASE WHEN A.MNAME IS NULL THEN '' ELSE ' ' + A.MNAME END + ' ' + A.LNAME FROM ALIAS A (NOLOCK)
INNER JOIN CLIENT_TO_ALIAS_COLLECTION AC (NOLOCK) ON AC.OID_LINK = A.OID
INNER JOIN ALIAS_TYPE AT (NOLOCK) ON AT.OID = A.ALIAS_TYPE_MONIKER
WHERE AT.ABBRNAME = 'Secure Client'
And AC.OID=@CLIENT_OID
AND A.EXPDATE IS NULL);
PLease let me know if this is better?
Thanks
Joe
March 8, 2012 at 4:36 pm
Still confused. I don't see any tables in the first query using the AT alias. I only see that in the subquery you are using the code snippit you show after the INSERT statement.
March 8, 2012 at 4:42 pm
Sorry Im fairly new and as u can tell didnt write what I showed..
Im trying to incorporate the second snippet into the first..
so if the person has an alias of "secure client" then do the alias code(Second part) if then don't
then just get the client name(First part)
Thanks
Joe
March 8, 2012 at 4:48 pm
Read the first article I reference below in my signature block. Follow the instructions on what you need to post. Also, post the expected results based on your sample data. The more information you provide the better help you will get.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply