this is 1 line, to get the data from a control, where it detects all the data from all columns.

SELECT ExtNo, TeacherID, Surname, Firstname, Location FROM [PhoneBook] WHERE (([ExtNo] LIKE ‘%’ + @ExtNo + ‘%’) OR (ltrim(rtrim(firstname))+space(1)+ltrim(rtrim(surname)) like ‘%’+ @Fullname + ‘%’) OR([Firstname] LIKE ‘%’ + @Firstname + ‘%’) OR ([Location] LIKE ‘%’ + @Location + ‘%’) OR ([Surname] LIKE ‘%’ + @Surname + ‘%’) OR ([TeacherID] LIKE ‘%’ + @TeacherID + ‘%’))”>

The key is here :(ltrim(rtrim(firstname))+space(1)+ltrim(rtrim(surname)) like ‘%’+ @Fullname + ‘%’)

Advertisements