Solved

Changing SQL Statement with Parameter

Posted on 2008-06-20
2
232 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 142

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
I have a large data set and a SSIS package. How can I load this file in multi threading?
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.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

785 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