【发布时间】:2013-06-04 06:19:50
【问题描述】:
我需要加入两个表,第一个表包含 CustomerNumber 和 IdentificationNumber,以及 IdentificationType。第二个表包含 IdentificationType、EffectiveDate 和 EndDate。
我的查询基本上是这样的:
Select CustomerNumber, IdentificationNumber
From Identification i
Inner Join IdentificationType it On it.IdentificationType = i.IdentificationType
And it.EffectiveDate < @TodaysDate
And (it.EndDate IS NULL Or it.EndDate > @TodaysDate)
我的执行计划显示了对标识类型表的聚集索引扫描,我假设这是因为连接子句中的 OR。
有没有更有效的加入方式,知道 EndDate 字段必须允许 Null 或真实的日期时间值?
【问题讨论】:
-
什么版本的 SQL Server?
-
能否请您出示执行计划?
-
对不起,SQL Server 2008R2
标签: sql sql-server