SQL Errors and Solutions
Error:
This login is the owner of 14 job(s). You must delete or reassign these jobs before the login can be dropped. (Microsoft SQL Server, Error: 15170)
Solution:
— **Changes the owner of the jobs to sa
DECLARE @pJobName VARCHAR(1000) DECLARE JobName_Crsr CURSOR FOR SELECT [name] FROM msdb..sysjobs WHERE owner_sid <> 0x01 OPEN JobName_Crsr FETCH NEXT FROM JobName_Crsr INTO @name_holder WHILE ( @@FETCH_STATUS <> -1 ) BEGIN EXEC msdb..sp_update_job @job_name = @pJobName, @owner_login_name = 'sa' FETCH NEXT FROM JobName_Crsr INTO @name_holder END CLOSE JobName_Crsr DEALLOCATE JobName_Crsr