Hi,
there's a method to concatenate fields in a WHERE clause?
I've a parameter which represents a name and surname of a person; in the table I've two fields representing one the name and the other the surname. I'd like to do a "LIKE" comparison concatenating Name and Surname field and confronting with my parameter... Is it possible?
Yes, it's possible.
WHERE Name + ' ' + Surname LIKE @.param
This may be another option:
WHERE Name LIKE @.param OR Surname LIKE @.param
Jos
|||Like this?
DECLARE @.NAMESTABLE (idint IDENTITY(1,1), Forenamevarchar(10), Surnamevarchar(10))DECLARE @.SEARCHNAMEvarchar(20)SET @.SEARCHNAME ='Mark Smith'INSERT @.NAMESVALUES ('Mark','Smith')SELECT *FROM @.NAMESWHERE Forename +' ' + Surname = @.SEARCHNAME|||
Jos has the solution... Tnx
No comments:
Post a Comment