Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_scriptreconwhereclause

  No additional text.


Syntax
create procedure sys.sp_scriptreconwhereclause
(
    @src_objid int
    ,@artid int
    ,@publishertype tinyint=1        -- 1 = mssqlserver, 2 = heterogeneous
)
as
begin
    declare @this_col int
                ,@art_col int
                ,@spacer nvarchar(10)
                ,@isset int
                ,@is_computed bit
                ,@rc int
                ,@cmd nvarchar(4000)
                ,@colname sysname
                ,@pubtypemssqlserver tinyint
                ,@pubtypeheterogeneous tinyint

    -- create WHERE clause

    select @art_col = 1
            ,@spacer = N' '
            ,@cmd = N'where'
            ,@pubtypemssqlserver = 1
            ,@pubtypeheterogeneous = 2
    -- prepare cursor based on publisher type
    if (@publishertype = @pubtypemssqlserver)
    begin
        DECLARE hCColid CURSOR LOCAL FAST_FORWARD FOR
            select column_id, name, is_computed from sys.columns where object_id = @src_objid order by column_id asc
    end
    else if (@publishertype = @pubtypeheterogeneous)
    begin
        DECLARE hCColid CURSOR LOCAL FAST_FORWARD FOR
            select colid, name, convert(bit,0) from IHsyscolumns where id = @src_objid order by colorder asc
    end
    else
    begin
        raiserror(21402, 16, 5, '@publishertype')
        return 1
    end

    OPEN hCColid
    FETCH hCColid INTO @this_col, @colname, @is_computed
    WHILE (@@fetch_status <> -1)
    begin
        exec @isset = sys.sp_isarticlecolbitset @this_col, @artid, @publishertype
        if @isset = 1
        begin
            -- processing a column this is marked for replication and is not computed
            exec @isset = sys.sp_MSiscolpk @src_objid, @this_col, @publishertype
            if @isset = 1
            begin
                -- processing a PK column
                select @cmd = @cmd + @spacer + quotename(@colname) + N' = @c' + convert( nvarchar, @art_col )
                select @spacer = N' and '

                if len( @cmd ) > 3000
                begin
                    insert into #proctext(procedure_text) values( @cmd )
                    select @cmd = N''
                end
                select @art_col = @art_col + 1
            end
            else
            begin
                --For computed columns that are not primary key columns,
                --the parameter index will not be incremented. This matches
                --the behavior in sp_scriptinsproccore
                if @is_computed = 0
                begin
                    select @art_col = @art_col + 1
                end
            end
        end
        FETCH hCColid INTO @this_col, @colname, @is_computed
    end
    CLOSE hCColid
    DEALLOCATE hCColid

    insert into #proctext(procedure_text) values( @cmd )
end

 
Last revision 2008RTM
See also

  sp_MSdrop_repltran (Procedure)
sp_scriptinsproccore (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