I'm building a stored procedure to return a set of records, yes nothing big.
The column is an NVarchar column and I'm using a select statement of
Select * from Table1
where Column1 Like @Column1
Table is currently one record containing the words: ***Some Test Word*** Is my test word
I've set the value of @Column1 to:
Some - no records returned
Some% - no records returned
%Some% - 1 record returned
% - 1 record returned
*% - no records returned
%*% - 1 record returned
%Not Here% - 1 record returned
Can someone tell me why if I have a leading and trailing wildcard I will get all records returned? Does it have something to do with the '*' characters in the field because some of my users are using these characters.
I've also tried changing the select to:
where RTRIM(Column1) Like @Column1 with the same result
where RTRIM(Column1) Like N'%' + @Column1 with the same result
What way should I give a user the way to search for a substring inside of an NVarchar field?
Oh, I tried using the Substring function and got the same result.
View Complete Post