Solved

Changing SQL Statement with Parameter

Posted on 2008-06-20
2
211 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
Comment Utility
= 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
Comment Utility
YAHTZEEEEEE !!!!
THANKS.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

763 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

6 Experts available now in Live!

Get 1:1 Help Now