Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_unlink_publication

  No additional text.


Syntax
create procedure sys.sp_unlink_publication
(
    @publisher sysname         -- publishing server name
    ,@publisher_db sysname    -- publishing database name
    ,@publication sysname      -- publication name
    ,@reserved nvarchar(10)=null -- 'drop all for all subscriptions'
)
as
begin
    set nocount on
    declare @retcode int
            ,@publisherlinkusertodrop sysname
            ,@objidtodrop int
            ,@cmd nvarchar(200)

    
    -- initialize
    
    select @retcode = 0
        ,@publisherlinkusertodrop = null

    exec @retcode = sys.sp_unlink_publication_internal
        @publisher = @publisher
        ,@publisher_db = @publisher_db
        ,@publication = @publication
        ,@reserved = @reserved
        ,@publisherlinkusertodrop = @publisherlinkusertodrop output

    if (@retcode != 0 or @@error != 0)
        return (1)

    
    -- Drop existing synctran triggers
    -- This must be done before dropping the link user
    
    if object_id('MSreplication_objects') is not null
    begin
        DECLARE #cur_trg CURSOR LOCAL FAST_FORWARD FOR
            SELECT object_id(object_name) FROM MSreplication_objects
                where object_type=N'T'
                and publication = @publication
                and publisher_db = @publisher_db
                and publisher = UPPER(@publisher) for read only
        open #cur_trg
        fetch #cur_trg into @objidtodrop

        while (@@fetch_status <> -1)
        begin
            exec @retcode = sp_MSdrop_object @object_id=@objidtodrop

            if @@error <> 0 or @retcode <> 0
            begin
                close #cur_trg
                deallocate #cur_trg
                return(1)
            end

            fetch next from #cur_trg into @objidtodrop
        end

        close #cur_trg
        deallocate #cur_trg
    end


    if @publisherlinkusertodrop is not null
    begin
        exec @retcode = sys.sp_dropuser @name_in_db = @publisherlinkusertodrop
        if @@error <> 0 or @retcode <> 0
            return (1)
    end
    return 0
end

 
Last revision 2008RTM
See also

  sp_droppullsubscription (Procedure)
sp_link_publication (Procedure)
sp_subscription_cleanup (Procedure)
sp_unlink_publication_internal (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