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 |
|
sanjay_jadam
Yak Posting Veteran
53 Posts |
Posted - 2005-12-13 : 02:36:23
|
| I have a stored proc and it takes 2 parameter @LocationIDs varchar(2000)@MarketIDs varchar(2000)From my UI i sends more than one locationID and marketID as string means something like thisLocationIDs = '2,3,4,5,6'MarketIDs = '3,5,4'but in my table LocationID and MarketID are integer.I worte a query likeSELECT * FROM LocationWHERE (LocationID IN (@LocationIDs) OR LocationID = NULL) and (MarketID IN (@MarketIDs) OR MarketID = NULL)I works when i pass one location id and marketidif i sends more than one it wont workHow can i solve this probThe one problem is that i can use EXEC becoz my client doesn't want it.Thanks |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-12-13 : 02:55:02
|
| SELECT * FROM LocationWHERE ('%'+@LocationIDs+'%' like '%'+cast(LocationID as varchar(5))+'%' OR LocationID IS NULL)and ('%'+@MarketIDs+'%' like '%'+cast(MarketID as varchar(5))+'%' OR MarketID IS NULL)MadhivananFailing to plan is Planning to fail |
 |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
|
|
sanjay_jadam
Yak Posting Veteran
53 Posts |
Posted - 2005-12-13 : 03:18:15
|
| thanksbut it works for locationID not for MarketIDi ran the query like thisproc sp_loc '2,3','2'Its not filtering the data by marketIDwhen i write like proc sp_loc '2,3' its working fine |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-12-13 : 03:20:15
|
| http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210&SearchTerms=WHERE+IN+@MyCSVKristen |
 |
|
|
sanjay_jadam
Yak Posting Veteran
53 Posts |
Posted - 2005-12-13 : 03:24:41
|
| thanks to allMy first approch working fine |
 |
|
|
|
|
|