Solved

Changing SQL Statement with Parameter

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

In this article I will describe the Copy Database Wizard 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.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
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 to return specific rows and columns, with various degrees of sorting and limits in place.

895 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now