我有这个SQL查询:
SELECT
@ComplianceCountAtAssociateDeptLevel = COUNT(FILUP.[FileUploadId])
,@TotalCountAtAssociateDeptLevel = COUNT(AD.[Associate_ID])
FROM
[CentralRepository].[dbo].[vw_CentralRepository_Associate_Details] AD WITH(NOLOCK)
LEFT JOIN
(select [FileUploadId],[AssociateID] from [CentralRepository].[dbo]. [vw_CentralRepository_FileUploadDetails]
where Fk_AppTemplateId =2 OR Fk_AppTemplateId=1 ) FILUP
ON AD.[Associate_ID] = FILUP.[AssociateID]
WHERE
AD.[Dept_ID] = 'SC00002'
它在5秒内获取结果。
但是,在将Dept_ID
参数声明为:
declare @Dept varchar(30) = 'SC00002',
并将其传递给WHERE
子句,如下所示:
WHERE
AD.[Dept_ID] = @Dept
请帮帮我。