Curley Braces in T/SQL?

  • Has anyone seen the following syntax in T/SQL?

    SELECT ReqPro.RqUserDefinedFieldValues.*

    , ReqPro.RqOverflowValues.OverflowFieldValue

    FROM

    {oj

    ReqPro.RqUserDefinedFieldValues

    LEFT OUTER JOIN ReqPro.RqOverflowValues

    ON (ReqPro.RqUserDefinedFieldValues.RequirementId= ReqPro.RqOverflowValues.OverflowRequirementId)

    AND (ReqPro.RqUserDefinedFieldValues.FieldId= ReqPro.RqOverflowValues.OverflowFieldId)

    }

    WHERE ReqPro.RqUserDefinedFieldValues.RequirementID=47

    ORDER BY ReqPro.RqUserDefinedFieldValues.FieldID

    I was wondering exactly why the CurleyBraces and "oj"?

  • It is MySql. The oj stands for Outer Join.

    The { OJ ... LEFT OUTER JOIN ...} syntax shown in the join syntax description exists only for compatibility with ODBC.

  • Thanks for that.

    Does that mean that SQL Server actually uses the {}, or is it just ignoring it and using the "LEFT OUTER JOIN"?

  • What you are seeing is syntax conforming to the ODBC specification. The braces are an ODBC escape sequence.

    You'll most often see this type of syntax with generated SQL statements from applications like MS Query or Crystal Reports.

    The SQL Server ODBC driver will translate any ODBC syntax into T-SQL on the fly, if it is not directly supported by the SQL Server database engine.

    You can get more information here:

    Microsoft ODBC Programmer's Reference: http://msdn.microsoft.com/en-us/library/ms714177%28VS.85%29.aspx

    And specifically for ODBC SQL Grammar: http://msdn.microsoft.com/en-us/library/ms709391%28VS.85%29.aspx

    -- J.Kozloski, MCDBA, MCITP

  • Great. Thanks for the response.

Viewing 5 posts - 1 through 4 (of 4 total)

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