Link to home
Start Free TrialLog in
Avatar of Charles Baldo
Charles BaldoFlag for United States of America

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.FirstName First,
      ClientInformation.LastName,
      ClientInformation.CompletedDate,
      ClientInformation.Certified

FROM      ClientInformation
          INNER JOIN Attorneys
            ON ClientInformation.AccessCode = Attorneys.AccessCode
WHERE      
     LoginID=@LoginID and
     ClientInformation.LastName LIKE @LastName

ASKER CERTIFIED SOLUTION
Avatar of geowrian
geowrian
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Charles Baldo

ASKER

No Error Just no Data
SOLUTION
Avatar of Raja Jegan R
Raja Jegan R
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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.