我继承维护了一台SQL Server(2008),我想修改一些系统存储过程。这些是用户定义的系统存储过程(例如:sys.sp_customproc)。我只能假设它们是作为系统过程创建的,因此它们可以在多个数据库之间共享?但无论如何,我需要修改它们。
这是其中之一的示例。
USE [msdb]
GO
/****** Object: StoredProcedure [sys].[sp_dbmmonitorhelpmonitoring] Script Date: 06/12/2013 13:16:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [sys].[sp_dbmmonitorhelpmonitoring]
as
begin
set nocount on
if (is_srvrolemember(N'sysadmin') <> 1 )
begin
raiserror(21089, 16, 1)
return (1)
end
declare @freq_type int, -- 4 = daily
@freq_interval int, -- Every 1 days
@freq_subday_type int, -- 4 = based on Minutes
@freq_subday_interval int, -- interval
@job_id uniqueidentifier,
@schedule_id int,
@retention_period int,
@jobname nvarchar( 256 )
select @jobname = isnull( formatmessage( 32047 ), N'Database Mirroring Monitor Job' )
select @job_id = job_id from msdb.dbo.sysjobs where name = @jobname
if (@job_id is null) -- if the job does not exist, error out
begin
raiserror( 32049, 16, 1 )
return 1
end
select @schedule_id = schedule_id from msdb.dbo.sysjobschedules where job_id = @job_id
select @freq_type = freq_type,
@freq_interval = freq_interval,
@freq_subday_type = freq_subday_type,
@freq_subday_interval = freq_subday_interval
from msdb.dbo.sysschedules where schedule_id = @schedule_id
-- If the frequency parameters are not what we expect then return an error
-- Someone has changed the job schedule on us
if (@freq_type <> 4) or (@freq_interval <> 1) or (@freq_subday_type <> 4)
begin
raiserror( 32037, 16, 1)
return 1
end
select @freq_subday_interval update_period
return 0
end
当我尝试执行它时,我收到错误:
消息 208,级别 16,状态 6,过程 sp_dbmmonitorhelpmonitoring,第 46 行无效的对象名称“sys.sp_dbmmonitorhelpmonitoring”。
我的登录名是“sa”,我被映射到 [msdb] 数据库中的用户“dbo”。如何修改此存储过程?