SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Creating an view with Option (Force order)


Creating an view with Option (Force order)

Author
Message
jaybmehta
jaybmehta
Valued Member
Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)

Group: General Forum Members
Points: 67 Visits: 1
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



Tao Klerks
Tao Klerks
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1529 Visits: 1249
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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search