Creating an view with Option (Force order)

  • Hello Sir

    I have a query which has an option(FORCE ORDER)

    ie

    select * from tab1 t1 inner join tab2 t2 on t1.c1 = t2.c1 inner join

    tab3 t3 on t3.c1 = t2.c1

    OPTION(FORCE ORDER)

    When i am executing this query alone its working fine..

    But when i try to make it as a view as this select statement then its giving a syntax error AS

    "Incorrect syntax near keyword OPTION"

    Can u have a view which has a select statement with OPTION FORCE ORDER, if please tell me the syntax for that

    Thnks in Advance

  • I stumbled across this abandoned post today while attempting to address the same issue, and thought I'd update it with my conclusion: It's simply not possible to specify the "OPTION (FORCE ORDER)" hint in a view definition (or, so that matter, any SELECT statement options), because the option can only ever be specified once per statement/query - it belongs in the final statement that actually uses the view.

    I would love to find an alternative, because guaranteeing that this hint is always specified on queries that use a particularly complex view can be onerous, or even unrealistic, but for now that seems to be the only option.

    http://poorsql.com for T-SQL formatting: free as in speech, free as in beer, free to run in SSMS or on your version control server - free however you want it.

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

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