Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return All if parameter is null

Status
Not open for further replies.

ZmrAbdulla

Technical User
Apr 22, 2003
4,364
AE
This must be covered earlier.. Please direct me if there is one.

I have a "view" like below.
Code:
SELECT     EmployeeName
FROM         tblEmployees
WHERE     (EmployeeName LIKE '%' + @EmployeeName + '%')ORDER BY EmployeeName

The Parmeter is taken from an asp.net page textbox. If nothing entered into the textbox then I need to return all data. How it can be done?

thanks


Return All if parameter is null

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Code:
SELECT EmployeeName
FROM   tblEmployees
WHERE  [!](@EmployeeName Is Null)
       Or [/!](EmployeeName LIKE '%' + @EmployeeName + '%')
ORDER BY EmployeeName

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Brilliant!
thanks Master!

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top