Hi all,
Is there a way to do something like:
DECLARE @TestID varchar(10),
@LastName varchar(70),
@FirstName varchar(30),
@MiddleName varchar(25),
@BirthDate datetime,
@SSN varchar(9),
@Address varchar(100),
@State char(2),
@Zip varchar(6)
SELECT @TestID=pr.TestID
FROM
TestA..Test r
INNER JOIN TestA..Sub pr
ON r.TempID = pr.TempID
LEFT JOIN TestA..Sub2 pa
on pa.TempID = pr.TempID
LEFT JOIN TestA..Sub3 pl
on pl.TempID = pr.TempID
LEFT JOIN TestA..Sub4 pd
on pd.TempID = pr.TempID
INNER JOIN TestA..FileA rf
ON r.FileAFileID = rf.FileAFileID
WHERE
r.FileAFileID = 12934 AND
@TsetID > '' AND
/*@LastName = pr.LastName, AND
@FirstName = pr.FirstName AND
@MiddleName = pr.MiddleName AND
@BirthDate = pr.BirthDate AND
@SSN = pr.SSN AND
@Address = pa.Address AND
@State = pa.State AND
@Zip = pa.PostalCode*/
Now, is there a way to have like the @LastName,@FirstName, @Middlename, etc happen IF the value contained isn't NULL and if it's not NULL then do the equals "=" like it is doing? It would be sorta like a CASE statement in a WHERE.
Anybody have any information on how something like this can be done?
Any information would be greatly appreciated.
Thanks
Is there a way to do something like:
DECLARE @TestID varchar(10),
@LastName varchar(70),
@FirstName varchar(30),
@MiddleName varchar(25),
@BirthDate datetime,
@SSN varchar(9),
@Address varchar(100),
@State char(2),
@Zip varchar(6)
SELECT @TestID=pr.TestID
FROM
TestA..Test r
INNER JOIN TestA..Sub pr
ON r.TempID = pr.TempID
LEFT JOIN TestA..Sub2 pa
on pa.TempID = pr.TempID
LEFT JOIN TestA..Sub3 pl
on pl.TempID = pr.TempID
LEFT JOIN TestA..Sub4 pd
on pd.TempID = pr.TempID
INNER JOIN TestA..FileA rf
ON r.FileAFileID = rf.FileAFileID
WHERE
r.FileAFileID = 12934 AND
@TsetID > '' AND
/*@LastName = pr.LastName, AND
@FirstName = pr.FirstName AND
@MiddleName = pr.MiddleName AND
@BirthDate = pr.BirthDate AND
@SSN = pr.SSN AND
@Address = pa.Address AND
@State = pa.State AND
@Zip = pa.PostalCode*/
Now, is there a way to have like the @LastName,@FirstName, @Middlename, etc happen IF the value contained isn't NULL and if it's not NULL then do the equals "=" like it is doing? It would be sorta like a CASE statement in a WHERE.
Anybody have any information on how something like this can be done?
Any information would be greatly appreciated.
Thanks