Solved

Using a wildcard in a where statement

Posted on 2015-02-13
1
94 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 75

Accepted Solution

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

728 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