Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSprepare_sub_for_detach

  No additional text.


Syntax
create procedure sys.sp_MSprepare_sub_for_detach
(
    @subscriber_server     sysname,
    @subscriber_db          sysname
)
as
begin
    set nocount on
    declare @detached     int
                ,@REPLICA_STATUS_BeforeRestore tinyint

    select @detached = 3
            ,@REPLICA_STATUS_BeforeRestore= 7

    -- Stage: attach and restore subscription.
    update dbo.MSreplication_restore_stage set stage_id = 2
    if @@error <> 0
        return 1

    /* Touch up the merge subscriptions for detach */
    if object_id(N'dbo.sysmergesubscriptions') is not NULL
    begin
        /* Mark all subscriptions to have a status of detached */
        update dbo.sysmergesubscriptions
            set status = @detached
            where UPPER(subscriber_server) collate database_default = UPPER(@subscriber_server) collate database_default and
                  db_name = @subscriber_db and
                  status <> @REPLICA_STATUS_BeforeRestore
        if @@error <> 0    return 1
    end

    if object_id(N'dbo.MSsub_identity_range') is not NULL
    begin
        -- Set range to 0 so that the attached db will get new ranges
        -- Refer to sp_MSsub_check_identity
        update dbo.MSsub_identity_range set range = 0
        if @@error <> 0
            return 1
    end

    if object_id(N'dbo.MSsubscription_properties', 'U') is not NULL
    begin
        -- clear out all login and passwords and use integrated where possible
        update dbo.MSsubscription_properties
            set publisher_login = NULL,
                publisher_password = NULL,
                publisher_security_mode = 1,
                distributor_login = NULL,
                distributor_password = NULL,
                distributor_security_mode = 1,
                ftp_login = NULL,
                ftp_password = NULL,
                dts_package_password = NULL,
                internet_password = NULL

        -- for transactional publications reset the publisher link information
        update dbo.MSsubscription_properties
            set publisher_security_mode = -1
                ,publisherlink = NULL
                ,publisherlinkuser = NULL
        where publication_type != 2
    end
end

 
Last revision 2008RTM
See also

  sp_copysubscription (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