Wild Card Concatenating with User Input

R

Roy

I am using an .adp file which is connected to the SQL
Server. I have created a query stored procedure. I now
am trying to search through one field, called NOTES, for
whatever the user inputs. In the criteria cell for the
column NOTES I type in:

LIKE "%" & @userinput & "%"

Userinput is basically the message box that appears so
the user can enter a phrase to search for. This does not
seem to work. Anybody have any solutions. Thank You!
 
S

Sylvain Lafontaine

You must add single quote ( ' ) to delimit strings in SQL:

LIKE "'%" & @userinput & "%'"

You must also take care that there are no single quote in the @userinput or
to replace them with 2 single quotes. In VBScript: userinput = replace
(userinput, "'", "''"). Sorry, I don't remember the exact syntaxe for doing
this in T-SQL right now.

S. L.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top