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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter datagrid with multiple values

Status
Not open for further replies.

neualex

Programmer
Feb 26, 2008
53
US
Hi guys,
I have a table as below:
SERVERNAME
STATUS
...where STATUS can be multiple values from another table (PRODUCTION, DEVELOPMENT and RETIRED)

So, I have this ASP.net page where I display 3 checkboxes (one per status) where the user can filter the list based on multiple values.

How would you implement this using a stored procedure?

I was thinking in passing a CSV parameter and using the IN clause, but T-SQL doesn't like it.
SET @list = 'production,development'
SELECT * FROM servers WHERE status IN (@list)

I found posts saying I need to convert the CSV into a table then link it to the IN clause, but I'd like to know from you guys...how would you implement it?

Thanks for the advice :)
...Alex
 
Ryan,

Yes, thank you. What I am looking for is suggestions if this is the best way to handle this multiple-value filter.

...Alex
 
Is it a big table? If not, I would download all the records and do the filtering on the client side. You then avoid multiple hits to the db everytime you change the filter.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top