Click here to Skip to main content
15,886,035 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How many levels can subqueries be nested in a FROM clause?
Posted
Comments
syed shanu 9-Dec-14 1:12am    
? can you give more details and with example
Ankur\m/ 9-Dec-14 1:22am    
I am not sure of the limit but that shouldn't bother you. Don't create a query with a lot of nested queries, that's not a good practice and is hard to understand and maintain.
barneyman 9-Dec-14 1:29am    
seriously? googling the same question ( https://www.google.com.au/search?q=How+many+levels+can+subqueries+be+nested+in+a+FROM+clause&oq=How+many+levels+can+subqueries+be+nested+in+a+FROM+clause&aqs=chrome..69i57j69i64&sourceid=chrome&es_sm=122&ie=UTF-8 ) gives you 4 answers before it finds your question

According to Microsoft the limit is 32 levels[^] for SQLServer.

Same limit in Oracle is 255[^].

If you're using some other DB you'll need to update your question and state what database you're using.
 
Share this answer
 
Comments
/\jmot 9-Dec-14 4:31am    
+5
According to Microsoft there is no technical limit - http://technet.microsoft.com/en-us/library/ms177501(v=sql.105).aspx[^]
However with any new nested level you introduce a performance problem, so think carefully...
 
Share this answer
 
Comments
Jörgen Andersson 9-Dec-14 4:14am    
I guess it depends on whether you decide to trust TechNet or MSDN.
Kornfeld Eliyahu Peter 9-Dec-14 4:28am    
In this case I have to - I never meet a single person that got so far to ask such a question :-)
Jörgen Andersson 9-Dec-14 5:30am    
I've seen the question before, I just can't imagine in what situation you would break the limit.
I'm working a lot with CTEs instead of subqueries, but I don't think I have ever reached more that six or seven level in depth.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900