View Single Post
Old 01-18-2013, 08:17 PM   PM User | #5
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,200
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Ummm...I think *NOT QUITE*, Alykins.

*IF* I understand him correctly:
Quote:
I want to search into datagrid Surname , Name with one textbox
I think he means he has *TWO* fields in the table, Surname and Name and wants to search for a match in *EITHER* of them.

So:
Code:
create proc usp_myDemo
    @name varchar()
AS
SELECT [fieldA], [fieldB], ... [fieldN]
FROM tbl_Demo
WHERE [SURNAME] = @name
OR [NAME] = @name
Or, if he means a more general search (e.g., Look for "ja" and find "James" or "Jane" or "Mojani") you would use:
Code:
create proc usp_myDemo
    @name varchar()
AS
SELECT [fieldA], [fieldB], ... [fieldN]
FROM tbl_Demo
WHERE [SURNAME] LIKE '%' + @name + '%'
OR [NAME] LIKE '%' + @name + '%'
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote