Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_cdc_restoredb_internal

  No additional text.


Syntax
create procedure [sys].[sp_cdc_restoredb_internal]
(
    @srv_orig sysname,
    @db_orig sysname,
    @keep_cdc int
)
with execute as 'dbo'
as
begin
    set nocount on

    declare @retcode int
            ,@db_curr sysname
            ,@force_remove_cdc int

    select @force_remove_cdc = 0
    select @db_curr = db_name()

    -- Verify SQL Server edition
    -- CDC is restricted to Eval, Enterprise and Developer editions
    --  For all other SKUs, we'll remove CDC
    IF (sys.fn_MSrepl_editionid () not in (30,31))
    BEGIN
        select @force_remove_cdc = 1
    END

    
    -- Upgrade the CDC metadata first, this insures that we have the proper version to remove
    
    exec @retcode = sys.sp_cdc_vupgrade
    if @retcode <> 0 or @@error <> 0
    begin
        return 1
    end

    
    -- If the original server name or database name are different (and the keep_cdc restore flag is not set)
    --   we'll want to remove CDC
    
    if (( UPPER(@srv_orig) <> UPPER(@@SERVERNAME) ) or ( @db_orig <> @db_curr )) and @keep_cdc = 0
    begin
        select @force_remove_cdc = 1
    end

    if @force_remove_cdc = 1
        and CONVERT(sysname,DATABASEPROPERTYEX(@db_curr,'updateability'))  = N'READ_WRITE'
			AND HAS_DBACCESS(@db_curr) = 1
			AND EXISTS(select * from sys.databases where db_id(@db_curr) = database_id and is_cdc_enabled = 1)
    begin
        exec @retcode = sys.sp_cdc_disable_db_internal
        if @retcode <> 0 or @@error <> 0
            return 1
    end

    return 0
end

 
Last revision 2008RTM
See also

  sp_cdc_restoredb (Procedure)
sp_MSdrop_cdc (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash