Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSiscolpk

  No additional text.


Syntax

create procedure sys.sp_MSiscolpk (
    @tabid int
    ,@colid int
    ,@publishertype tinyint=1        -- 1 = mssqlserver, 2 = heterogeneous
)
as
begin

    if (@publishertype = 1)
    begin
        -- mssqlserver publisher
        declare @pkindid int, @indkey int, @objname nvarchar(300)

        if objectproperty(@tabid, 'IsTable') = 1
        begin
            if exists (select indexcols.index_column_id
                         from sys.indexes inds
                   inner join sys.index_columns indexcols
                           on inds.index_id = indexcols.index_id
                          and inds.object_id = indexcols.object_id
                          and inds.object_id = @tabid
                          and inds.is_primary_key = 1
                        where indexcols.column_id = @colid
                          and indexcols.is_included_column = 0)
            begin
                return 1
            end
        end
        else if objectproperty(@tabid, 'IsView') = 1
        begin
            if exists (select index_column_id
                         from sys.index_columns
                        where object_id = @tabid
                          and index_id = 1 -- clustered index
                          and column_id = @colid)
            begin
                return 1
            end
        end

        return 0



        if exists( select * from sys.objects where object_id = @tabid and type = 'V' )
        begin
            select @pkindid = 1
        end
        else
        begin
            select @pkindid = index_id from sys.indexes where object_id = @tabid and is_primary_key = 1
        end
        select @indkey = 1
        select @objname = QUOTENAME(schema_name(OBJECTPROPERTY(@tabid, 'SchemaId'))) collate database_default + N'.' collate database_default + QUOTENAME(object_name( @tabid )) collate database_default
        while @indkey <= 16 and index_col( @objname, @pkindid, @indkey ) is not null
        begin
            if exists (select column_id from sys.columns where object_id = @tabid
                    and name = index_col( @objname, @pkindid, @indkey ) and column_id = @colid)
                return 1
            select @indkey = @indkey + 1
        end
    end
    else if (@publishertype = 2)
    begin
        -- heterogenous publisher
        declare @pubcolid int

        SELECT    @pubcolid = publishercolumn_id
        FROM    IHcolumns
        WHERE    @tabid = article_id
        AND    @colid = column_id

        if exists (SELECT    ihpc.publishercolumn_id
                    FROM IHcolumns ihc, IHpublishercolumns ihpc, IHpublishercolumnconstraints ihpcc,
                            IHpublisherconstraints ihpcn, IHarticles iha
                    WHERE ihpcn.publisher_id = iha.publisher_id
                            and    ihpcn.table_id = iha.table_id
                            and    ihc.publishercolumn_id = ihpc.publishercolumn_id
                            and    ihpc.publishercolumn_id = ihpcc.publishercolumn_id
                            and    ihpcn.publisherconstraint_id = ihpcc.publisherconstraint_id
                            and    iha.article_id = @tabid
                            and    ihpcn.type = 'PRIMARYKEY'
                            and    ihpc.publishercolumn_id = @pubcolid)
        return 1
    end
    else
    begin
        raiserror(21402, 16, 15, '@publishertype')
    end
    -- all done
    return 0
end

 
Last revision 2008RTM
See also

  sp_MSareallcolpkcomputed (Procedure)
sp_MSscript_compensating_insert (Procedure)
sp_MSscript_params (Procedure)
sp_scriptdelproccore (Procedure)
sp_scriptinsproccore (Procedure)
sp_scriptpkwhereclause (Procedure)
sp_scriptpubwinsrefreshcursorvars (Procedure)
sp_scriptreconwhereclause (Procedure)
sp_scriptupdateparams (Procedure)
sp_scriptupdproccore (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