Charles Baldo
asked on
Need to use parameter in like clause
Hi
I need to use a parameter in a like clause. This will become a stored procedure. How do I do this?
DECLARE @LoginID varchar(30)
DECLARE @LastName varchar(4)
SET @LoginID='LI123'
SET @LastName='smith'
SELECT
Attorneys.LoginID,
ClientInformation.FirstNam e First,
ClientInformation.LastName ,
ClientInformation.Complete dDate,
ClientInformation.Certifie d
FROM ClientInformation
INNER JOIN Attorneys
ON ClientInformation.AccessCo de = Attorneys.AccessCode
WHERE
LoginID=@LoginID and
ClientInformation.LastName LIKE @LastName
I need to use a parameter in a like clause. This will become a stored procedure. How do I do this?
DECLARE @LoginID varchar(30)
DECLARE @LastName varchar(4)
SET @LoginID='LI123'
SET @LastName='smith'
SELECT
Attorneys.LoginID,
ClientInformation.FirstNam
ClientInformation.LastName
ClientInformation.Complete
ClientInformation.Certifie
FROM ClientInformation
INNER JOIN Attorneys
ON ClientInformation.AccessCo
WHERE
LoginID=@LoginID and
ClientInformation.LastName
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Both of the coding solutions worked. It was the question by geowrian that me me realize what the issue was. I was not getting an error I was getting nop data. It was a logic error of the DECLARE @LastName varchar(4) 4 bytes was not enough. Once I fixed that my code worked.
ASKER
Both of the coding solutions worked. It was the question by geowrian that me me realize what the issue was. I was not getting an error I was getting nop data. It was a logic error of the DECLARE @LastName varchar(4) 4 bytes was not enough. Once I fixed that my code worked.
ASKER