Maximum number of joins allowed in single SQL statement

Posted on 2006-05-18
Last Modified: 2008-01-09
I have a gigantic SQL statement that has 10 left outer joins and 2 inner joins. what is the maximum number of joins SQL will allow...i tried adding another left join but got this error message:
The correlation name 'Foreign Key' is specified multiple times in a FROM clause.
Question by:felkamau
    LVL 3

    Expert Comment

    Maybe just paste in the from clause so we can see.
    LVL 32

    Accepted Solution

    You can have up to 256 table references (and thus, that many joins) in one SELECT statement.

    However, the error you reference has nothing to do with this limit.  Instead, it implies that you have named two separate table instances with the same alias - 'Foreign Key'.  Check your table aliases.
    LVL 3

    Expert Comment

    I agree with bhess1, sure would help if we had the from clause :)

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
    Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now