I try to use stored procedure to do a search for Email column. But I always get a error "Incorrect syntax near '.'", when I input keyword like "ash11.tw." And if I put keyword without dot, it works fine. It seems like the dot caused the problem. But I dont know how to fix it. Can someone help me out? Thanks.
My where expression is following.
@.spWhereSearch = 'where cont.Email like "%' + @.Email + '%"'
Try this@.spWhereSearch = Where cont.Email Like "'% + @.Email + %'"|||
Probably try this
@.spWhereSearch = 'where cont.Email like %' + @.Email + '%'
|||Change the double quotes " in your where search to two single quotes '' and that should fix your issue.
|||Thanks for answering.
I have tried above three but they still dont work.
The error is still the same.
Does anyone have other suggestions?
|||If you show us the code then it would be more helpful. I dont see any reason why this would fail
@.spWhereSearch = Where cont.Email Like '% + @.Email + %'|||That line needs to look *exactly* like this (which was Motley's suggestion and is the resolution to your prolem):
@.spWhereSearch = 'where cont.Email like ''%' + @.Email + '%'''
|||
Thanks for replying. it works!!!
tmorton and Motley's suggestion is correct.
Thanks again.
No comments:
Post a Comment