Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

Sql: are following two queries different (Left out join 'on' vs. 'where')?

$
0
0

Declare BigTable table (KeyColumn1 int, KeyColumn2 int,

KeyColumn3 int, KeyColumn4 money, column5 nvarchar (25))

Declare @Temptable table (KeyColumn1 int, KeyColumn2 int,

KeyColumn3 int, KeyColumn4 money, column5 nvarchar (25))

@Temptable  has several thousand rows

Bigtable has million rows

Do the following two queries have any differnet?

Delete dbo.BigTable with (Rowlock) From dbo.BigTable i Left Outer Join @Temptable ii on i.KeyColumn1= ii.KeyColumn1and i.KeyColumn2= ii.KeyColumn2

and i.KeyColumn3= ii.KeyColumn3 and i.KeyColumn4 = ii.KeyColumn4 Where i.KeyColumn1= @IntNumber and i.KeyColumn3= @IntPeriod

and ii.KeyColumn1is Null and ii.KeyColumn2 is Null and ii.SubPeriod is Null and ii.PriceSoldAt is Null vs. Delete dbo.BigTable with (Rowlock) From dbo.BigTable i Left Outer Join @Temptable ii on i.KeyColumn1= @IntNumber and i.KeyColumn4 = @IntPeriod and i.KeyColumn1 = ii.KeyColumn1 and i.KeyColumn2 = ii.KeyColumn2 and i.KeyColumn3 = ii.KeyColumn3 and i.KeyColumn4 = ii.KeyColumn4 Where ii.KeyColumn1is Null and ii.KeyColumn2 is Null and ii.KeyColumn3 is Null and ii.KeyColumn4 is Null



JaneC



Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>