0

SQL Server (2008) のメンテナンスを継承しており、システム ストアド プロシージャの一部を変更したいと考えています。これらは、ユーザー定義のシステム ストアド プロシージャです (例: sys.sp_customproc)。複数のデータベース間で共有できるように、システム プロシージャとして作成されたとしか思えませんか? とにかく、私はそれらを変更する必要があります。

そのうちの 1 つの例を次に示します。

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' にマップされています。このストアド プロシージャを変更するにはどうすればよいですか?

4

1 に答える 1

0

SP を「システム ストアド プロシージャ」としてマークすると、その SP を変更することはできません。代わりに、削除して再作成し、再度システム ストアド プロシージャとしてマークする必要があります (sp_ms_marksystemobject を使用)。「システム」としてマークされたものをいじることがいかに非常に危険であるかをすでに理解していると思います. これを試みる前に、たくさんのバックアップを作成することを強くお勧めします。つまり、マスター、モデル、および MSDB をバックアップします。

于 2013-06-12T20:49:32.700 に答える