Query LIKE operator

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
Back
Top