嗨,我有一个简单的查询,如下所示:
declare @lastuploadd INT
set @lastuploadd=(select max([UploadID]) from [MYTABLE]);
INSERT INTO MYTABLE
SELECT [UploadID]
, [UpLd_Status]
, CAST([Date_Uploaded] AS DATE)
, USRID
, [EID]
, coalesce(nl.PRODUCTtype, nli.PRODUCTtype, nlis.PRODUCTtype)
,COUNT([PRODUCT_id])
FROM [SOURCETABLE] e
JOIN [FILETABLE] dfp ON dfp.UploadID=e.UploadID
LEFT JOIN [NLPROD] nl on e.[PRODUCT_id]=nl.[PRD_ID]
LEFT JOIN [NLPROD] nli on e.[PRODUCT_id]=nli.[PRD]
LEFT JOIN [NLPROD] nlis on e.[PRODUCT_id]=cast(nlis.[PRDID] as varchar (55))
WHERE dfp.UploadID>@lastuploadd and [PRODUCT_id] is not null
GROUP BY [UploadID]
, [UpLd_Status]
, CAST([Date_Uploaded] AS DATE)
, USRID
, [EID]
, coalesce(nl.PRODUCTtype, nli.PRODUCTtype, nlis.PRODUCTtype)
问题是,当我尝试运行它时,它将永远运行。因此,我尝试终止会话,但实际上是不可能的-工作站的任务状态一直处于KIILED / ROLLBACK状态,并且仍在运行。要摆脱此会话,我需要重新启动服务。
但是: 当我删除变量并在其中放一个整数
WHERE dfp.UploadID>@lastuploadd
然后它起作用。没有任何问题。 查询
select max([UploadID]) from [MYTABLE]
返回整数。
有什么想法吗?
编辑:值得一提:源表位于另一台链接服务器上,与MYTABLE不同。在活动监视器中,我看到“等待类型” = OLEDB