Hi all,
I have a stored procedure that generates the following SQL WHERE clause
UserName LIKE 'Adi234%' AND Fname LIKE 'David%' AND LName LIKE 'Justin%' AND
It is good except that it i can not remove the last AND which is not neccessary at the end of the clause.
I want to remove the last AND that come up at the end, my code places AND after each data field(UserName, Fname, Lname) .
Thanks
a quick and dirty way: add
1=1
after the query (which always is good
|||In your stored procedure, you can use a Substring to remove the end AND:
Assume @.strSQL is the SQL statement string you are returning now. Add this line:
SET @.strSQL=SUBSTRING(@.strSQL, 0,LEN(@.strSQL)-3)
|||Thanks Limno, that works great
No comments:
Post a Comment