MSDN“缺少连接谓词事件类”表示“表示正在执行没有连接谓词的查询”。
但不幸的是,这似乎并不那么容易。
例如,非常简单的情况:
create table #temp1(i int);
create table #temp2(i int);
Select * from #temp1, #temp2 option (recompile);
Run Code Online (Sandbox Code Playgroud)
表中没有数据,也没有警告,尽管它显然没有连接谓词。
如果我查看 SQL Server 2005 的文档(相同的链接,只是其他服务器版本),会有一句额外的句子:“仅当连接的双方返回多于一行时才会产生此事件。 ”这将使在以前的情况下完美的感觉。没有数据,所以双方都返回0行,没有警告。插入行,得到警告。嗯不错。
但是对于下一个令人困惑的情况,我在两个表中插入相同的值:
Insert into #temp1 (i) values (1)
Insert into #temp1 (i) values (1)
Insert into #temp2 (i) values (1)
Insert into #temp2 (i) values (1)
Run Code Online (Sandbox Code Playgroud)
我得到:
-- no warning:
Select * from #temp1 t1
inner join #temp2 t2 on t1.i = t2.i
option (recompile)
-- has warning:
Select * from …Run Code Online (Sandbox Code Playgroud) 我正在对性能不佳的存储过程的点点滴滴进行故障排除。程序的这一部分抛出了一个 NO JOIN PREDICATE 警告
select
method =
case methoddescription
when 'blah' then 'Ethylene Oxide'
when NULL then 'N/A'
else methoddescription
end,
testmethod =
case methoddescription
when 'blah' then 'Biological Indicators'
when NULL then 'N/A'
else 'Dosimeter Reports'
end,
result =
case when l.res is null or l.res <> 1 then 'Failed'
else 'Passed'
end,
datecomplete = COALESCE(CONVERT(varchar(10), NULL, 101),'N/A')
from db2.dbo.view ls
join db1.dbo.table l
on ls.id = l.id
where item = '19003'
and l.id = '732820'
Run Code Online (Sandbox Code Playgroud)
视图 ( …