title: order hint for openquery?
body: <p>I need to execute the following SQL (<em>SQL Server 2008</em>) in a scheduled job periodically. The Query plan shows 53% cost is <em>sort</em> after the data is pulled from the oracle server. However, I've ordered the data in the openquery. How to force the query not to sort when merge joining? </p>
  
  <pre><code>merge target as t
  using (select * from openquery(oracle, '
           select * from t1 where UpdateTime &gt; ''....'' order by k1, k2')
        ) as s on s.k1=t.k1 and s.k2=t.K2 -- the clustered PK of "target" is K1,k2
  when matched then ...... 
  when not matched then ......
  </code></pre>
  
  <p>Is there something like <code>bulk insert</code>'s "<code>with (order( { column [ ASC | DESC ] } [ ,...n ] ))</code>"? will it help improve the query plan of the <code>merge</code> statement if it exists?</p>
  
  <p>If the oracle table already have PK on K1,K2, will just using <code>oracle.db.owner.tablename</code> as target better? (will SQL Server figure out the index from oracle meta information?)</p>
  
  <p>Or the best I can do is stored the oracle data in a local temp table and create a clustered primary key on K1,k2? I am trying to avoid to create a temp table because sometime the returned openquery data set can be large.</p>