sql server - How to concatenate row values for use in WHERE clause of T-SQL query -


i want write query in t-sql perform search on 2 concatenated columns. 2 columns fname , lname. here have far:

select     fname,     lname,     ...     users join     othertable on foo=bar     fname+' '+lname '%query%' 

sql server doesn't syntax, though. how structure query can perform operation searches through 2 concatenated columns, allowing me search user's full name, rather first name , last name individually?

i can suggest 1 of fname or lname null fails., (null concat null)

try

... isnull(fname, '') + ' ' + isnull(lname, '') '%query%' 

however, use computed column , consider indexing because run awfully.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -