AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / dba / 问题 / 45988
Accepted
Jez
Jez
Asked: 2013-07-10 01:11:42 +0800 CST2013-07-10 01:11:42 +0800 CST 2013-07-10 01:11:42 +0800 CST

还原数据库时对象名称“master.dbo.MSreplication_options”无效

  • 772

我试过用谷歌搜索这个问题的答案,但一无所获。

我有一个 SQL Server 实例,其复制设置为FooDatabase. 我有第二个实例,其复制设置为FooDatabase第一个实例的订阅者。复制更新工作。我想要做的是备份订阅FooDatabase,在订阅者实例上删除它,然后恢复备份。但是,当我这样做并尝试恢复备份时,我收到以下错误:

服务器“DAVEG1525-162”的恢复失败。(Microsoft.SqlServer.SmoExtended)

System.Data.SqlClient.SqlError:对象名称“master.dbo.MSreplication_options”无效。(Microsoft.SqlServer.Smo)

我已经检查并dbo.MSreplication_options确实作为系统表存在于生产实例的master数据库中,但不存在于订阅实例上。

我的问题是:如果订阅实例上不存在它,为什么它会包含在从 SQL Server 订阅实例制作的备份中?我该如何解决这个问题?

sql-server-2008-r2 replication
  • 1 1 个回答
  • 4536 Views

1 个回答

  • Voted
  1. Best Answer
    Jez
    2013-07-11T01:40:26+08:002013-07-11T01:40:26+08:00

    据我所知,master.dbo.MSreplication_options无论您是否设置了复制,该表以及其他各种与复制相关的表都应该存在于任何 SQL Server 2008 r2 安装中。不知何故,我的 SQL Server 实例上的那个被删除了。我最终在 Google(缓存!)上找到了这个方便的脚本,它“修复”了各种复制的东西,包括master.dbo.MSreplication_options如果它不存在则重新创建:

    -- ***************************************************************************
    -- Copyright (c) 1997 - 2003 Microsoft Corporation.
    -- All Rights Reserved
    --
    -- @File: ReplicationFixup.sql
    --
    -- Purpose:
    --  Procedures/extended stored procedures (XPs)/functions that are owned by replication and are created on master database
    --  
    -- Notes: Created 2001/02/07 10:28 (RMak)
    --
    -- History:
    --
    --     @Version: Yukon
    --
    -- @EndHeader@
    --
    exec sys.sp_configure 'update',1
    reconfigure with override
    
    set ANSI_NULLS off
    
    use master
    go
    
    -- Make sure that we remove procedures that got accidentally installed in 
    -- master by an 80 sp2 QFE
    if object_id('dbo.sp_MSreplremoveuncdir', 'P') > 0
        drop procedure dbo.sp_MSreplremoveuncdir
    
    if object_id('dbo.sp_MSdeletefoldercontents', 'P') > 0
        drop procedure dbo.sp_MSdeletefoldercontents
    
    -- drop extended procedures that were created in master
    
    if object_id('xp_mergexpusage', 'local') is not null
        execute sys.sp_dropextendedproc 'xp_mergexpusage'
    
    if object_id('xp_mergelineages', 'local') is not null
        execute sys.sp_dropextendedproc 'xp_mergelineages'
    
    if object_id('xp_mapdown_bitmap', 'local') is not null
        execute sys.sp_dropextendedproc 'xp_mapdown_bitmap'
    
    if object_id('xp_ORbitmap', 'local') is not null
        execute sys.sp_dropextendedproc 'xp_ORbitmap'
    
    if object_id('xp_firstonly_bitmap', 'local') is not null
        execute sys.sp_dropextendedproc 'xp_firstonly_bitmap'
    
    if object_id('xp_varbintohexstr', 'local') is not null
        execute sys.sp_dropextendedproc 'xp_varbintohexstr'
    
    if object_id('xp_intersectbitmaps', 'local') is not null
        execute sys.sp_dropextendedproc 'xp_intersectbitmaps'
    
    if object_id('xp_displayparamstmt', 'local') is not null
        execute sys.sp_dropextendedproc 'xp_displayparamstmt'
    
    if object_id('xp_printstatements', 'local') is not null
        execute sys.sp_dropextendedproc 'xp_printstatements'
    
    if object_id('xp_makecab', 'local') is not null
        exec sys.sp_dropextendedproc 'xp_makecab'
    
    if object_id('xp_unpackcab', 'local') is not null
        exec sys.sp_dropextendedproc 'xp_unpackcab'
    
    if object_id('sp_repldone', 'local') is not null
        exec sys.sp_dropextendedproc 'sp_repldone'
    
    if object_id('sp_repltrans', 'local') is not null
        exec sys.sp_dropextendedproc 'sp_repltrans'
    
    if object_id('sp_replcounters', 'local') is not null
        exec sys.sp_dropextendedproc 'sp_replcounters'
    
    if object_id('sp_replhelp', 'local') is not null
        exec sys.sp_dropextendedproc 'sp_replhelp'
    
    if object_id('sp_replddlparser', 'local') is not null
        exec sys.sp_dropextendedproc 'sp_replddlparser'
    
    if object_id('sp_replcmds', 'local') is not null
        exec sys.sp_dropextendedproc 'sp_replcmds'
    
    if object_id('sp_replflush', 'local') is not null
        exec sys.sp_dropextendedproc 'sp_replflush'
    
    if object_id('sp_replpostcmd', 'local') is not null
        exec sys.sp_dropextendedproc 'sp_replpostcmd'
    
    if object_id('sp_replincrementlsn_internal', 'local') is not null
        exec sys.sp_dropextendedproc 'sp_replincrementlsn_internal'
    
    if object_id('sp_replupdateschema', 'local') is not null
        exec sys.sp_dropextendedproc 'sp_replupdateschema'
    
    if object_id('sp_replsetoriginator_internal', 'local') is not null
        exec sys.sp_dropextendedproc 'sp_replsetoriginator_internal'
    
    if object_id('sp_replsetsyncstatus', 'local') is not null
        exec sys.sp_dropextendedproc 'sp_replsetsyncstatus'
    
    if object_id('sp_replpostsyncstatus_int', 'local') is not null
            exec sys.sp_dropextendedproc 'sp_replpostsyncstatus_int'
    
    if object_id('xp_dsninfo', 'local') is not null
        exec sys.sp_dropextendedproc 'xp_dsninfo'
    
    if object_id('xp_enumdsn', 'local') is not null
        exec sys.sp_dropextendedproc 'xp_enumdsn'
    
    if object_id('xp_oledbinfo', 'local') is not null
        exec sys.sp_dropextendedproc 'xp_oledbinfo'
    
    if object_id('xp_repl_encrypt', 'local') is not null
        exec sys.sp_dropextendedproc 'xp_repl_encrypt'
    
    if object_id('xp_repl_convert_encrypt', 'local') is not null
        exec sys.sp_dropextendedproc 'xp_repl_convert_encrypt'
    
    if object_id('xp_repl_help_connect', 'local') is not null
        exec sys.sp_dropextendedproc 'xp_repl_help_connect'
    
    if object_id('xp_replproberemsrv', 'local') is not null
        exec sys.sp_dropextendedproc 'xp_replproberemsrv'
    
    go
    
    --
    -- Create table dbo.MSreplication_options in master if needed
    --
    if object_id(N'dbo.MSreplication_options', 'local') is null
    BEGIN
        -- table does not exist
        raiserror('Creating table MSreplication_options',0,1)
    
        CREATE TABLE dbo.MSreplication_options 
        (
            optname sysname NOT NULL,
            value bit NOT NULL,
            major_version int NOT NULL,
            minor_version int NOT NULL,
            revision int NOT NULL,
            install_failures int NOT NULL
        )
    
        exec dbo.sp_MS_marksystemobject N'dbo.MSreplication_options'
    END
    ELSE
    BEGIN
        -- table exists 
        -- drop index if needed (this index was used in Sphinx)
        if exists (select * from sys.indexes where object_id = object_id(N'dbo.MSreplication_options')
                            and name = N'ucMSreplication_options')
        begin
            drop index dbo.MSreplication_options.ucMSreplication_options
        end
    END
    GO
    
    IF NOT EXISTS (SELECT * FROM MSreplication_options WHERE optname = 'transactional')
        INSERT INTO MSreplication_options VALUES
            ('transactional',0,0,0,0,0)
    IF NOT EXISTS (SELECT * FROM MSreplication_options WHERE optname = 'merge')
        INSERT INTO MSreplication_options VALUES
            ('merge',0,0,0,0,0)
    IF NOT EXISTS (SELECT * FROM MSreplication_options WHERE optname = 'security_model')
    BEGIN
        DECLARE @major_version  int,
                @minor_version  int,
                @revision       int
    
        -- @@microsoftversion is set as 0xMMmmRR[RR] wher M=Major, m=minor and R=revision
        --  SELECT @major_version   = CONVERT(int, SUBSTRING(CONVERT(varbinary(4), @@microsoftversion), 1, 1)), 
        --      @minor_version  = CONVERT(int, SUBSTRING(CONVERT(varbinary(4), @@microsoftversion), 2, 1)),
        --      @revision       = CONVERT(int, SUBSTRING(CONVERT(varbinary(4), @@microsoftversion), 3, 2))
        SELECT @major_version   = 90,
                @minor_version  = 0,
                @revision       = 0
    
        INSERT INTO MSreplication_options (optname, value, major_version, minor_version, revision, install_failures) 
            VALUES ('security_model', 1, @major_version, @minor_version, @revision, 0)
    END
    
    UPDATE MSreplication_options
        SET major_version = 90
    GO
    
    -- Startup procs have to be created in master
    if object_id('sp_MSrepl_startup', 'local') is not null
        drop procedure sp_MSrepl_startup  
    
    raiserror('Creating procedure sp_MSrepl_startup', 0,1)
    go
    
    create procedure dbo.sp_MSrepl_startup
    as
        exec sys.sp_MSrepl_startup_internal
    go
    
    exec master.dbo.sp_MS_marksystemobject sp_MSrepl_startup
    
    -- If a distributor is installed, mark the sp as a startup sp. 
    if exists (select * FROM master..sysservers WHERE  srvstatus & 8 <> 0)
        exec dbo.sp_procoption 'sp_MSrepl_startup', 'startup', 'true' 
    go
    
    if object_id('sp_MScleanupmergepublisher', 'local') is not null
        drop procedure sp_MScleanupmergepublisher
    go
    
    SET ANSI_NULLS ON
    SET ANSI_WARNINGS ON
    
    raiserror('Creating procedure sp_MScleanupmergepublisher', 0,1)
    go
    create procedure dbo.sp_MScleanupmergepublisher
    as
        exec sys.sp_MScleanupmergepublisher_internal
    go
    
    -- If there are any merge published databases installed on this server, 
    -- mark sp_MScleanupmergepublisher as a startup proc
    
    if exists (select * from master..sysdatabases where (category & 4) <> 0)
        exec dbo.sp_procoption 'sp_MScleanupmergepublisher', 'startup', 'true'
    
    --
    -- Functions that used to be created in master and have now moved to resource
    -- use exec to drop, otherwise "drop function" gives syntax error on SQL 7, which did not have UDFs yet
    --
    
    if object_id('fn_varbintohexstr', 'local') is not null
         exec('drop function dbo.fn_varbintohexstr')
    
    if object_id('fn_varbintohexsubstring', 'local') is not null
         exec('drop function dbo.fn_varbintohexsubstring')
    
    go
    
    --
    -- procedures that used to be created in master and are obsolete now
    -- drop the local procedures in master
    --
    if object_id(N'dbo.sp_addpublisher', 'local') is not null
        drop procedure dbo.sp_addpublisher
    
    if object_id(N'dbo.sp_fetchshowcmdsinput', 'local') is not null
        drop procedure dbo.sp_fetchshowcmdsinput
    
    if object_id(N'dbo.sp_getagentoffloadinfo', 'local') is not null
        drop procedure dbo.sp_getagentoffloadinfo
    
    if object_id(N'dbo.sp_gettypestring', 'local') is not null
        drop procedure dbo.sp_gettypestring
    
    if object_id(N'dbo.sp_helpmergecleanupwait', 'local') is not null
        drop procedure dbo.sp_helpmergecleanupwait
    
    if object_id(N'dbo.sp_helpsubscriptionjobname', 'local') is not null
        drop procedure dbo.sp_helpsubscriptionjobname
    
    if object_id(N'dbo.sp_mergecompletecleanup', 'local') is not null
        drop procedure dbo.sp_mergecompletecleanup
    
    if object_id(N'dbo.sp_mergepreparecleanup', 'local') is not null
        drop procedure dbo.sp_mergepreparecleanup
    
    if object_id(N'dbo.sp_MSaddpubtocontents', 'local') is not null
        drop procedure dbo.sp_MSaddpubtocontents
    
    if object_id(N'dbo.sp_MSareallcolumnscomputed', 'local') is not null
        drop procedure dbo.sp_MSareallcolumnscomputed
    
    if object_id(N'dbo.sp_MSchunkgeneration', 'local') is not null
        drop procedure dbo.sp_MSchunkgeneration
    
    if object_id(N'dbo.sp_MScleanup_metadata', 'local') is not null
        drop procedure dbo.sp_MScleanup_metadata
    
    if object_id(N'dbo.sp_MScleanuptask', 'local') is not null
        drop procedure dbo.sp_MScleanuptask
    
    if object_id(N'dbo.sp_MScompletecleanup', 'local') is not null
        drop procedure dbo.sp_MScompletecleanup
    
    if object_id(N'dbo.sp_MScomputearticlescreationorder', 'local') is not null
        drop procedure dbo.sp_MScomputearticlescreationorder
    
    if object_id(N'dbo.sp_MScomputeunresolvedrefs', 'local') is not null
        drop procedure dbo.sp_MScomputeunresolvedrefs
    
    if object_id(N'dbo.sp_MSdelete_specifiedcontents', 'local') is not null
        drop procedure dbo.sp_MSdelete_specifiedcontents
    
    if object_id(N'dbo.sp_MSdeletecontents', 'local') is not null
        drop procedure dbo.sp_MSdeletecontents
    
    if object_id(N'dbo.sp_MSdeletepushagent', 'local') is not null
        drop procedure dbo.sp_MSdeletepushagent
    
    if object_id(N'dbo.sp_MSenumchanges_direct', 'local') is not null
        drop procedure dbo.sp_MSenumchanges_direct
    
    if object_id(N'dbo.sp_MSenumchanges_pal', 'local') is not null
        drop procedure dbo.sp_MSenumchanges_pal
    
    if object_id(N'dbo.sp_MSenumpartialchanges_direct', 'local') is not null
        drop procedure dbo.sp_MSenumpartialchanges_direct
    
    if object_id(N'dbo.sp_MSenumpartialchanges_pal', 'local') is not null
        drop procedure dbo.sp_MSenumpartialchanges_pal
    
    if object_id(N'dbo.sp_MSexternalfkreferences', 'local') is not null
        drop procedure dbo.sp_MSexternalfkreferences
    
    if object_id(N'dbo.sp_MSget_subtypedatasrc', 'local') is not null
        drop procedure dbo.sp_MSget_subtypedatasrc
    
    if object_id(N'dbo.sp_MSgettypestringudt', 'local') is not null
        drop procedure dbo.sp_MSgettypestringudt
    
    if object_id(N'dbo.sp_MShelpsubscriptionjobname', 'local') is not null
        drop procedure dbo.sp_MShelpsubscriptionjobname
    
    if object_id(N'dbo.sp_MSinsertcontents', 'local') is not null
        drop procedure dbo.sp_MSinsertcontents
    
    if object_id(N'dbo.sp_MSis_col_replicated', 'local') is not null
        drop procedure dbo.sp_MSis_col_replicated
    
    if object_id(N'dbo.sp_MSload_replication_status', 'local') is not null
        drop procedure dbo.sp_MSload_replication_status
    
    if object_id(N'dbo.sp_MSmakedynsnapshotvws_longdef', 'local') is not null
        drop procedure dbo.sp_MSmakedynsnapshotvws_longdef
    
    if object_id(N'dbo.sp_MSpreparecleanup', 'local') is not null
        drop procedure dbo.sp_MSpreparecleanup
    
    if object_id(N'dbo.sp_MSquiescecheck', 'local') is not null
        drop procedure dbo.sp_MSquiescecheck
    
    if object_id(N'dbo.sp_MSquiesceforcleanup', 'local') is not null
        drop procedure dbo.sp_MSquiesceforcleanup
    
    if object_id(N'dbo.sp_MSquiescetriggersoff', 'local') is not null
        drop procedure dbo.sp_MSquiescetriggersoff
    
    if object_id(N'dbo.sp_MSquiescetriggerson', 'local') is not null
        drop procedure dbo.sp_MSquiescetriggerson
    
    if object_id(N'dbo.sp_MSreplcheck_connection', 'local') is not null
        drop procedure dbo.sp_MSreplcheck_connection
    
    if object_id(N'dbo.sp_MSscript_security', 'local') is not null
        drop procedure dbo.sp_MSscript_security
    
    if object_id(N'dbo.sp_MSscript_validate_subscription', 'local') is not null
        drop procedure dbo.sp_MSscript_validate_subscription
    
    if object_id(N'dbo.sp_MSscriptmvastable', 'local') is not null
        drop procedure dbo.sp_MSscriptmvastable
    
    if object_id(N'dbo.sp_MSscriptmvastableidx', 'local') is not null
        drop procedure dbo.sp_MSscriptmvastableidx
    
    if object_id(N'dbo.sp_MSscriptmvastablenci', 'local') is not null
        drop procedure dbo.sp_MSscriptmvastablenci
    
    if object_id(N'dbo.sp_MSscriptmvastablepkc', 'local') is not null
        drop procedure dbo.sp_MSscriptmvastablepkc
    
    if object_id(N'dbo.sp_MSsubst_filter_name', 'local') is not null
        drop procedure dbo.sp_MSsubst_filter_name
    
    if object_id(N'dbo.sp_MSupdate_replication_status', 'local') is not null
        drop procedure dbo.sp_MSupdate_replication_status
    
    if object_id(N'dbo.sp_MSupdatecontents', 'local') is not null
        drop procedure dbo.sp_MSupdatecontents
    
    if object_id(N'dbo.sp_replicationoption', 'local') is not null
        drop procedure dbo.sp_replicationoption
    
    if object_id(N'dbo.sp_replproberemoteserver', 'local') is not null
        drop procedure dbo.sp_replproberemoteserver
    
    if object_id(N'dbo.sp_replsetoriginator_pal', 'local') is not null
        drop procedure dbo.sp_replsetoriginator_pal
    
    if object_id(N'dbo.sp_verify_publication', 'local') is not null
        drop procedure dbo.sp_verify_publication
    
    if object_id(N'dbo.sp_MSarticletextcol', 'local') is not null
        drop procedure dbo.sp_MSarticletextcol
    
    if object_id(N'dbo.sp_MSexists_file', 'local') is not null
        drop procedure dbo.sp_MSexists_file
    
    if object_id(N'dbo.sp_MSfixlineagemismatch', 'local') is not null
        drop procedure dbo.sp_MSfixlineagemismatch
    
    if object_id(N'dbo.sp_MStextcolstatus', 'local') is not null
        drop procedure dbo.sp_MStextcolstatus
    
    if object_id(N'dbo.sp_MSread_resolver_clsid', 'local') is not null
        drop procedure dbo.sp_MSread_resolver_clsid
    
    if object_id(N'dbo.sp_MSsubscriptions', 'local') is not null
        drop procedure dbo.sp_MSsubscriptions
    
    go
    

    After I ran this, I was able to import my backed-up DB on the subscriber without error.

    • 5

相关问题

  • 如何阻止 MySQL 从站将更改复制到“mysql”数据库?

  • 在同一台物理服务器上运行复制是不明智的吗?

  • 有没有办法以小于 1 秒的分辨率测量 MySQL 中的复制滞后?

  • 运行时间偏移延迟复制的最佳实践

  • PostgreSQL 9.0 Replication 和 Slony-I 有什么区别?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    授予用户对所有表的访问权限

    • 5 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    pedrosanta 使用 psql 列出数据库权限 2011-08-04 11:01:21 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve