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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Querying Vast # of Records

Author  Topic 

jeff0228
Starting Member

2 Posts

Posted - 2011-11-18 : 11:36:13
I am trying to run the following query below in Oracle:

Select Acct_Num, Customer_Name
From Database
Where Acct_Num IN (
1,
4,
104
..,
..,
192384,
200002
)

When I attempt to run the query, I get the error message: "ORA-01795 maximum number of expressions in a list is 1000"


Is there any way I can execute this query w/o having to break the 'IN' list up by 1,000 Acct_Num over numerous amount of times? Please note that I know the 50,000+ accounts I want the info on but they are not ordered and they mix ranges with accounts I don't want. Therefore I can't use a 'BETWEEN' clause. Thank you!!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-18 : 11:39:19
why not put these values in a temporary table first and join to that? much better than using IN

Also please keep in mind that this is ms sql server forum so if you want oracle specific help try in some oracle forums like www.orafaq.com

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

jeff0228
Starting Member

2 Posts

Posted - 2011-11-18 : 11:51:40
Thank you. Appreciate it.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-11-21 : 03:19:04
Also, I dont think SQL Server has a restriction in IN clause

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -