Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-03-25 : 16:47:46
|
Deepak writes "I have a front end in asp which allow user to check for status of different items in a database
like checkbox1 : Items1 checkbox2 : Items2 checkbox3 : Items3 checkbox4 : Items4 checkbox5 : Items5
this list is genearated by asp page dynamically user can check as many values as he want value of checkboxes are ids of item in database table
STATUS TABLE
---------------------- ID Status ---------------------- 1 ok 2 defected 3 not available
on page submit as check which checkboxes are checked and then make a string which is comma seperated list of ids like "2,3,9" which i pass to a store procedure get_status_by_ids
create proc get_status_by_ids @ids as varchar(200) as begin select id,status from status where id in ( select @ids ) end
this procedure works fine if user chooses only one checkbox but if users checks more than one check boxs then it fails
I have thinks two solutions for this but none is good enough (i think!)
1) create a dynamic sql within the store proc then execute it .but this defeat the purpose of store procedure.
2) create a temp table in the store proc and parse the @ids string and insert id in temp table and than make a inner join with status table to give result ( too much work for sql server creating a temp table ...)
can this problem be solved with derived table if yes can you give me full solution for this ? Is there any other way to solve this problem
Looking for an intelligent reply
Deepak Verma" |
|
|
|
|
|