Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MScreate_article_repl_view

  No additional text.


Syntax

create procedure sys.sp_MScreate_article_repl_view
    @pubid uniqueidentifier,
    @artid uniqueidentifier
as
begin

    declare @artid_str nvarchar(50)
            , @pubid_str nvarchar(50)
            , @retcode int
            , @repl_view_name nvarchar(260)
            , @repl_view_id int
            , @qualified_table_name nvarchar(270)
            , @cmd nvarchar(max)
            , @source_objid int

    exec @retcode=sys.sp_MSguidtostr @artid, @artid_str output
    if @retcode<>0 or @@ERROR<>0 return (1)

    exec @retcode=sys.sp_MSguidtostr @pubid, @pubid_str output
    if @retcode<>0 or @@ERROR<>0 return (1)

    select @repl_view_name = 'dbo.MSmerge_repl_view_' + @pubid_str + '_' + @artid_str

    if object_id(@repl_view_name) is not null
    begin
        exec ('drop view ' + @repl_view_name)
        if @@ERROR<>0 return (1)
    end

    select @qualified_table_name =
        (select quotename(SCHEMA_NAME(o.schema_id)) from sys.objects o where o.object_id = v.objid) + '.' +
        quotename(object_name(v.objid)),
        @source_objid = v.objid
    from dbo.sysmergepartitioninfoview v
    where v.artid = @artid
    and v.pubid = @pubid

    -- the following will be true for a light weight subscription
    if @qualified_table_name is NULL
        return 0

    select @cmd = 'create view ' + @repl_view_name + ' as select * from ' + @qualified_table_name +
            ' where ({fn ISPALUSER(''' + convert(nvarchar(36), @pubid) + ''')} = 1 or permissions(' + convert(nvarchar(12),@source_objid) + ') & 0x1b <> 0)'

    exec (@cmd)
    if @@ERROR<>0
    begin
        select @retcode = 1
        goto FAILURE
    end

    exec ('grant select on ' + @repl_view_name + ' to public')
    if @@ERROR<>0
    begin
        select @retcode = 1
        goto FAILURE
    end

    execute dbo.sp_MS_marksystemobject @repl_view_name
    if @@ERROR<>0
    begin
        select @retcode = 1
        goto FAILURE
    end

    update dbo.sysmergepartitioninfo set repl_view_id = object_id (@repl_view_name)
    where pubid = @pubid and artid = @artid

    select @retcode = 0
FAILURE:

    return @retcode
end

 
Last revision 2008RTM
See also

  sp_addmergearticle (Procedure)
sp_MSaddmergetriggers (Procedure)
sp_MScreate_all_article_repl_views (Procedure)
sp_MScreate_article_repl_views (Procedure)
sp_MSdrop_rladmin (Procedure)
sp_MSsetup_publication_for_partition_groups (Procedure)
sp_MSupdatesysmergearticles (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