Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I want pass '([phonenumber] like '%%')' in varchar in sql server.but I received error 'Incorrect syntax near ')'.' while executing. Please help.
Posted
Comments
Abhinav S 19-Oct-15 4:32am    
Post the query here so that someone may try and help you.

 
Share this answer
 
if you mean you want to insert the string:
SQL
INSERT INTO MyTable (MyColumn) VALUES ('([phonenumber] like '%%')')

Then it's not the percent sign that causes the problem - it's the quote characters.
SQL
INSERT INTO MyTable (MyColumn) VALUES ('([phonenumber] like ''%%'')')
Will fix that.
If you means that you want phone numbers that start and end with a percent character then try:
SQL
SELECT * FROM MyTable WHERE phonenumber LIKE '[%]%[%]'

If that isn't what you want either, then we need much better information.
 
Share this answer
 
select * from MyTable where ohonenumber like '%' + @phonenumber + '%'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900