Solved

Changing SQL Statement with Parameter

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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
Star schema daily updates 2 39
query analyser in sql server 2016 express edition 2 26
T-SQL to copy a database 37 67
How come this XML node is not read? 3 32
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
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.

730 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