SQL server 2008, I have a table which stored the created Job_id for each job and then for deleting the job I use a stored procedure (below) which gets the ID and tries to delete the job but although I'm sure that the job exists with @ScheduleReportID but the following select always returns null ! Job_id is of type UniqueIdentifier in tbRptSchedule
SQL server 2008,我有一个表,它为每个作业存储创建的Job_id,然后删除作业我使用存储过程(下面)获取ID并尝试删除作业但是我确信作业存在使用@ScheduleReportID,但以下select始终返回null! Job_id在tbRptSchedule中的类型为UniqueIdentifier
declare @job_name nvarchar(max)
SELECT @job_name = name
from msdb.dbo.sysjobs with(nolock)
where job_id = (select job_id from dbo.tbRptSchedule with(nolock) where ScheduledReportID = @ScheduledReportID)
IF @job_name IS NULL
BEGIN
RAISERROR ('Cannot find Job identifier',16,1)
END