i need query which starts with first name here is my query:
if(@firstName <> '')
BEGIN
set @queryString = @queryString+ ' and UPPER(col_FirstName) like ''%' +@firstName +'%'''
END
if(@lastName <> '')
BEGIN
set @queryString = @queryString + ' and UPPER(col_LastName) like ''%' +@lastName +'%'''
but it is searching first name in middle also i want to search only with initials letters
thanks
Both masks in your constructed condition specify that the search be performed anywhere in the column value:
The percent sign in the mask stands for “any number of any characters”. Placed before the search term, therefore, it would match a value where the search term (
@firstName) is preceded by any number of characters. To specify that thecol_FirstNamevalue should start with the@firstNamevalue (and possibly have an arbitrary number of characters afterwards), just remove the leading percent, i.e. like this: