Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSdropconstraints

  No additional text.


Syntax
-- This will be called merge at the subscriber side, check for dbo permission
create procedure sys.sp_MSdropconstraints
    @table sysname,
    @owner sysname = null
as
    declare @const_name nvarchar(258)
    declare @objid int
    declare @retcode int
    declare @qualified_tablename   nvarchar(517)
    declare @quoted_tablename   nvarchar(270)
    declare @quoted_ownername   nvarchar(270)

    /*
    ** Check for subscribing permission
    */
    exec @retcode=sys.sp_MSreplcheck_subscribe
    if @retcode<>0 or @@ERROR<>0 return (1)

    select @quoted_tablename = quotename(@table)

    if @owner is not NULL
    begin
        set @quoted_ownername = QUOTENAME(@owner)
        set @qualified_tablename= @quoted_ownername + '.' + @quoted_tablename
    end
    else
        set @qualified_tablename= @quoted_tablename

    set @objid = object_id(@qualified_tablename)
    if @objid is null
    begin
        if @owner is null
        begin
            select @objid = object_id from sys.objects
                where name=@quoted_tablename
        end
        else
        begin
            select @objid = object_id from sys.objects
                where name=@quoted_tablename and schema_name(schema_id)=@quoted_ownername
        end
    end
    if @objid is NULL
        return (1)

    select @const_name = QUOTENAME(object_name(object_id)) from
        sys.foreign_keys where parent_object_id = @objid

    while @const_name is not null
    begin
        exec ('alter table ' + @qualified_tablename +
            ' drop constraint ' + @const_name)
        if @@ERROR <> 0
            return (1)
        set @const_name = NULL
        select @const_name = QUOTENAME(object_name(object_id)) from
            sys.foreign_keys where parent_object_id = @objid
    end

    return (0)

 
Last revision 2008RTM
See also

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