我有一个永远不会完成执行的存储过程。尽管该表已编入索引,但即使有 80,000 条记录,它也会失败。我尝试使用 Adam Machanic 脚本,发现以下语句永远不会终止。我知道问题出在 where 子句之后。
PS 参数嗅探并非如此。
insert into ProcessedFile_396 (Name,Phone,Title,Address,company,domain,SIC,NAICS,Industry,Email,UploadedB2bFiled_id) select
b.Name,
b.Phone,
b.Title,
case when isnull(b.Street,'') <> '' then isnull(b.Street,'') +',' else '' end +
case when isnull(b.city,'') <> '' then isnull(b.city,'') + ',' else '' end +
case when isnull(b.state,'') <> '' then isnull(b.state,'') + ',' else '' end +
case when isnull(b.zip,'') <> '' then isnull(b.zip,'') + '.' else '' end as Address,
(select top 1 Company from CompanyWebsite where domain = b.domain) as Company,
b.domain,
b.SIC,
b.NAICS,
b.Industry,
b.Email,
B2bFiled_id
from
UploadedFile_396 a, B2bDB b
where
((a.CompanyDomain = b.domain and ISNULL(a.CompanyDomain,'') <> ''))
and
((a.Name = b.Name or a.FirstName = b.FirstName or a.LastName = b.LastName or a.MiddleName = b.MiddleName)
and
(ISNULL(a.Name,'') <> '' or ISNULL(a.FirstName,'') <> '' or ISNULL(a.LastName,'') <> '' or ISNULL(a.MiddleName,'') <> '' ))
group by
B2bFiled_id,b.Name,b.Phone,b.Title,b.Street,b.City,b.State,b.Zip,b.domain,b.domain,b.SIC,b.NAICS,b.Industry,b.Email