Sorry, but that WHERE clause is really muddled up.
I'm confused as to the sample column value, did the message get sent to the same person (bezlan) twice?
And you did not answer my question. :) What value are you passing in as the @receivername value?
The purpose of the LIKE operator is to allow for partial matches. If you insist that it is also = to a specific value, then it can't work as a partial match. That's because a partial match has to have wildcard characters in it.
Wildcard characters are % and _
% means any combination of values of any length. _ means any one character's worth of values.
So, like '%bezlan%' would find match any occurance of bezlan in the string.
If you are passing in the user's name you want to find messages for, what's the point of joining to Profile("UserName")? If Profile("UserName") knows the user that is logged in, what's the point of using @receivername? Seems to me that only one of those
values is needed.
Is Profile() a sql database function in your database? I don't recognize it. Or is it a C# or VB method? Because if it's a C# or VB function, it has no business in the middle of a SQL statement.
If that's correct, then
WHERE [receivername] LIKE '% ' + somevalue + ' %'
Replace somevalue with @receivername if you decide to use that as your parameter or Profile('UserName') if that is a sql database function.
If this answered your question, be sure to mark it as the answer. That way, everybody after you will know it's the answer also!
Marked as answer by jbear123 on Nov 29, 2007 09:09 AM
david wendel...
All-Star
15865 Points
2243 Posts
Re: Selecting data wheere values contain something
Nov 18, 2007 05:23 PM|LINK
Sorry, but that WHERE clause is really muddled up.
I'm confused as to the sample column value, did the message get sent to the same person (bezlan) twice?
And you did not answer my question. :) What value are you passing in as the @receivername value?
The purpose of the LIKE operator is to allow for partial matches. If you insist that it is also = to a specific value, then it can't work as a partial match. That's because a partial match has to have wildcard characters in it.
Wildcard characters are % and _
% means any combination of values of any length. _ means any one character's worth of values.
So, like '%bezlan%' would find match any occurance of bezlan in the string.
If you are passing in the user's name you want to find messages for, what's the point of joining to Profile("UserName")? If Profile("UserName") knows the user that is logged in, what's the point of using @receivername? Seems to me that only one of those values is needed.
Is Profile() a sql database function in your database? I don't recognize it. Or is it a C# or VB method? Because if it's a C# or VB function, it has no business in the middle of a SQL statement.
If that's correct, then
Replace somevalue with @receivername if you decide to use that as your parameter or Profile('UserName') if that is a sql database function.