PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework Query LIKE operator

Reply

Query LIKE operator

 
Thread Tools Rate Thread
Old 03-03-2006, 04:44 PM   #1
=?Utf-8?B?Sm9u?=
Guest
 
Posts: n/a
Default Query LIKE operator


I thought that the LIKE operator would return a partial value search. Suppose
you want a client name Smith and you enter a partial value of Smi, should
that locate it?

Here is my query code. This code works as long as you type the entire name.

SELECT [CODE], [Stable], [HorseName], [NickName], [Active], [MainWork],
[LastDate], [Weeks], [DueDate], [LastCost], [Totals], [AngleLF], [AngleRF],
[AngleLH], [AngleRH], [LengthLF], [LengthRF], [LengthLH], [LengthRH],
[SizeLF], [SizeRF], [SizeLH], [SizeRH], [StartAngleLF], [StartAngleRF],
[StartAngleLH], [StartAngleRH], [StartLengthLF], [StartLengthRF],
[StartLengthLH], [StartLengthRH], [NeedsNewFr], [NeedsNewHd], [Front],
[Hind], [Delete], [AngleList], [LengthList] FROM [Horse]
WHERE HorseName LIKE (@HName)

Thanks Jon Stroh
  Reply With Quote
Old 03-03-2006, 05:21 PM   #2
David Owen
Guest
 
Posts: n/a
Default Re: Query LIKE operator

This probably isn't the correct group to post this question; you may want to
look at a group like the sqlserver.programming group.

However, I think what you need is to put a "%" at the end of the search
string. The end of the query would read:

set @HName = @HName + '%'
....
where HorseName like (@HName)

HTH
David

"Jon" <Jon@discussions.microsoft.com> wrote in message
news:FE20713D-286E-4241-BCDE-ECF7702C6E73@microsoft.com...
>I thought that the LIKE operator would return a partial value search.
>Suppose
> you want a client name Smith and you enter a partial value of Smi, should
> that locate it?
>
> Here is my query code. This code works as long as you type the entire
> name.
>
> SELECT [CODE], [Stable], [HorseName], [NickName], [Active], [MainWork],
> [LastDate], [Weeks], [DueDate], [LastCost], [Totals], [AngleLF],
> [AngleRF],
> [AngleLH], [AngleRH], [LengthLF], [LengthRF], [LengthLH], [LengthRH],
> [SizeLF], [SizeRF], [SizeLH], [SizeRH], [StartAngleLF], [StartAngleRF],
> [StartAngleLH], [StartAngleRH], [StartLengthLF], [StartLengthRF],
> [StartLengthLH], [StartLengthRH], [NeedsNewFr], [NeedsNewHd], [Front],
> [Hind], [Delete], [AngleList], [LengthList] FROM [Horse]
> WHERE HorseName LIKE (@HName)
>
> Thanks Jon Stroh



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off