Wild Card Concatenating with User Input

  • Thread starter Thread starter Roy
  • Start date Start date
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!
 
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.
 
Back
Top