what does {} do in T-SQL

  • I have inherited a T-SQL script from a developer and have found the following statement, which has a set of braces. I have no idea what this does. Can anyone explain it to me please.

    from{oj PORTFOLIO A0 WITH(NOLOCK) LEFT OUTER JOIN PORTFOLIOARREST A1 WITH(NOLOCK)

    LEFT OUTER JOIN ACCOUNTARREST A2 WITH(NOLOCK)

    LEFT OUTER JOIN POSITIONARREST A3 WITH(NOLOCK)

    LEFT OUTER JOIN SECURITY A4 WITH(NOLOCK)

    LEFT OUTER JOIN SECURITY A5 WITH(NOLOCK)

    LEFT OUTER JOIN SECURITY A6 WITH(NOLOCK)

    LEFT OUTER JOIN FUND A7 WITH(NOLOCK)

    LEFT OUTER JOIN FUNDSTYLE A8 WITH(NOLOCK) ON A7.FUNDSTYLE = A8.FUNDSTYLESEEDID

    ON A6.SECURITYSEEDID = A7.SECURITYSEEDID

    ON A5.FATHER = A6.SECURITYSEEDID

    LEFT OUTER JOIN FUND A9 WITH(NOLOCK)

    LEFT OUTER JOIN FUNDSTYLE A10 WITH(NOLOCK) ON A9.FUNDSTYLE = A10.FUNDSTYLESEEDID

    ON A5.SECURITYSEEDID = A9.SECURITYSEEDID

    ON A4.FATHER = A5.SECURITYSEEDID LEFT OUTER JOIN FUND A11 WITH(NOLOCK)

    INNER JOIN FUNDSTYLE A12 WITH(NOLOCK) ON A11.FUNDSTYLE = A12.FUNDSTYLESEEDID

    ON A4.SECURITYSEEDID = A11.SECURITYSEEDID

    ON A3.SECURITY = A4.SECURITYSEEDID

    ON A2.AASEEDID = A3.ACCOUNTARREST

    ON A1.PASEEDID = A2.PORTFOLIOARREST

    ON A0.PORTFOLIOSEEDID = A1.PORTFOLIO}

    Kind Regards

    Paul

  • You can't use {} without the oj. I just learned this by trying it in SSMS and without the oj it throws an error. It is ODBC outer join syntax. Here is the error I get:

    Msg 155, Level 15, State 1, Line 8

    '[first text following {]' is not a recognized ODBC outer join option.

  • Thanks very much for the fast response. Much appreciated.

    I have just found my question answered here in more detail:

    http://www.sqlservercentral.com/Forums/Topic514126-8-1.aspx

    If anyone else is interested.

    Kind Regards

    Paul

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply