Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using a wildcard in a where statement

Posted on 2015-02-13
1
Medium Priority
?
106 Views
Last Modified: 2015-02-13
I have  a field 'NAME' that can contain first and last names.
I would like to have a textbox that can collect a submitted last name to perform a  search....something like :

Select * FROM tblCustomers
WHERE NAME LIKE '%SMITH'
This would return all John Smith, Fred Smith and so on...

I have a stored procedure that will be referencing a textbox called 'txtNAME'. In my where statement how would the wildcard look?   NAME LIKE '%' + @NAME ? (@NAME is the declared variable)
0
Comment
Question by:ITMikeK
1 Comment
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 2000 total points
ID: 40608377
Select * FROM tblCustomers
 WHERE NAME LIKE '%'+@name
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question