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 |
|
omega1983
Starting Member
40 Posts |
Posted - 2009-08-17 : 15:42:47
|
| alter procedure school_lookup1@schoolyear1 char (2) = ''@schoolyear2 char (2) = ''@schoolyear3 char (2) = ''@degreeyear1 char (4) = ''@degreeyear2 char (4) = ''@degreeyear3 char (4) = ''@schoolname1 char (65) = ''@schoolname2 char (65) = ''@schoolname3 char (65) = ''asselect schoolid, schoolyear,schoolname,degreeyearfrom school_lookup1where schoolyear in (@schoolyear1,@schoolyear2,@schoolyear3)and degreeyear in (@degreeyear1,@degreeyear2,@degreeyear3)and schoolname in (@schoolname1,@schoolname2,@schoolname3)Is there a way to re-work this stored procedure so that it can capture a range of the forementioned values. For example, the degree years go back to 1900 and I would not want to do parameters for all those years |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-08-17 : 16:02:12
|
| yes. have one parameter @schoolyears varchar(8000). It would take values like '71,72,75'have one parameter @schoolnames varchar(8000). It would take values like 'school1, school2'use a couple instances of a table valued split function as a table JOINed to your school_lookup1 table.EDIT:lookf for this section:CSV / Splitting delimited listsin this topic:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210Be One with the OptimizerTG |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-08-18 : 02:38:47
|
| Aslo read Sommarskog's article on Arrays in SQL Server.MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|