Solved

Changing SQL Statement with Parameter

Posted on 2008-06-20
2
242 Views
Last Modified: 2010-04-21
I have the following sql statement in my MS Studio 2008 C# project that is connected to a sql server database:

cmd.CommandText = "SELECT DISTINCT * FROM MORTGEE WHERE MORTGEE_NAME = (@MN) ORDER BY MORTGEE_NAME ";

I would like to change this to a "LIKE" statement, I.E. LIKE (@MN).

I can't figure out the code, any ideas?

Thanks,

JD
0
Comment
Question by:jamesdean666
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 21834044
= or LIKE should both work... however, in the value of @mn that you pass you need the wildcards as needed, OR
cmd.CommandText = "SELECT DISTINCT * FROM MORTGEE WHERE MORTGEE_NAME LIKE '%' + @MN + '%' ORDER BY MORTGEE_NAME ";

Open in new window

0
 

Author Closing Comment

by:jamesdean666
ID: 31469291
YAHTZEEEEEE !!!!
THANKS.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

861 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