none
OUTER APPLY Alias within the OUTER APPLY and then the OUTER APPLY Alias itself RRS feed

  • Question

  • We are trying to set-up some Alias standards for OUTER/CROSS APPLY. Just wondering if anyone has some suggestions as to how to best alias OUTER/CROSS APPLY Tables within the Parentheses and then aliasing the OUTER/CROSS APPLY result itself to try and keep all of this straight. We are trying to make our aliases as less painful as possible. So we are thinking something like this...

    OUTER APPLY (
    SELECT ...
    FROM [Schema].[TableName] AS [OuterApply.TableAlias]
    INNER JOIN [Schema].[TanleName2] AS [OuterApply.TableAlias2]
    ON Blah Blah Blah
    ) AS [OuterApply1.TableAlias]
    
    OUTER APPLY (
    SELECT ...
    FROM [Schema].[TableName] AS [OuterApply.TableAlias]
    INNER JOIN [Schema].[TanleName2] AS [OuterApply.TableAlias2]
    ON Blah Blah Blah
    ) AS [OuterApply2.TableAlias]

    Thanks for your review and am hopeful for a reply.

    Tuesday, November 19, 2019 5:24 PM

All replies

  • Hi,

    As far as I know, there are no specific rules for the use of aliases in SQLServer. As long as it doesn't violate the syntax, it can make your code work correctly. If you want to make it easy to use, you can name it according to your own code structure, which may be easy to use.

    Hope it will help you.

    Best Regards,

    Rachel 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, November 20, 2019 6:31 AM