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 - 2006-12-06 : 07:47:00
|
| Sanjeev writes "Dear sir,Can anybody tell me that how many values we can put into IN() operator , like:Select * from Table1 where groupid IN(12,52,65,45,1,2,3,4,5,6,7,8,9........)We have a condition in which we have to put more than 5 thousande values coma seperated, is it possible?sanjeev dhimannoida, india" |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-06 : 07:49:27
|
| BAD IDEA!Store the number in a temporary table instead and join against that.Most probably, the 5000 values together with comma would exceed the 8000 char limit.Peter LarssonHelsingborg, Sweden |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2006-12-06 : 07:49:34
|
Even if it's possible, it's not desirable or efficient. Insert the values into a temp table or table variable and JOIN that:INSERT #tbl(groupid) select 12 groupid union all select 1 union all select 2 --yada yada, however you need to fill this tableSelect T1.* from Table1 T1 INNER JOIN #tbl T2 ON T1.groupid=T2.groupid<edit> Yeah, what he said 7 seconds before me (I provided code at least...with comments) </edit> |
 |
|
|
|
|
|
|
|