0
我試圖調試此查詢沒有任何成功。 IN如果我註釋掉Pt.pt_id_nbr下面的代碼它的工作原理否則查詢保留執行很長一段時間調試此查詢所需的指針
Declare @sAlias char(1),
@sGQOrgId char(3),
@sID char(12),
@sType char(1),
@sSource char(2),
@dcLocationId numeric(18, 0) = NULL
set @sAlias='N'
set @sGQOrgId =''
Set @sID =''
Set @sType ='M'
Set @sSource ='MD'
SELECT DISTINCT
'' 'ImportID',d.GQOrgId, d.DeviceId
--,isnull(Pt.Pt_id_nbr,0)as Pt_id_nbr
--,Pt.pt_id_nbr works if commented out else the query keeps executing for a long time
, DeviceDesc = LTRIM(RTRIM(d.DeviceDesc)), d.Source,
SourceDesc = LTRIM(RTRIM(s.SourceDesc))
FROM GasQuality.dbo.Device AS d WITH (NoLock)
JOIN GasQuality.dbo.SourceCodes AS s WITH (NoLock)
ON s.Source = d.Source
left join elm_qa.elm.dbo.pt_sys_xref as Pt WITH (NoLock)
ON d.DeviceID = Pt.REF_VAL and (Pt.OLD_SYS_ID = 'PK' and Pt.VAL_TYPE_CD = 'OM')
WHERE s.Type = @sType AND
d.GQOrgId LIKE RTRIM(@sGQOrgId) + '%'
AND d.Source LIKE RTRIM(@sSource) + '%'
AND d.DeviceId LIKE RTRIM(@sID) + '%'
ORDER BY d.GQOrgId, d.DeviceId, d.Source
查看快速運行的查詢和不運行的查詢之間的執行計劃 – HLGEM
我無權查看執行路徑 – sanika