Re: Constraints: disable / enable constraints issue

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Kalen Delaney (replies_at_public_newsgroups.com)
Date: 10/27/04

  • Next message: Sri: "statistics - one more"
    Date: Wed, 27 Oct 2004 13:47:10 -0700
    
    

    Hi Leida

    Foreign keys can be disabled using the ALTER TABLE command. Please see Books
    Online for full syntax, or have Enterprise Manager script the operation to
    show you the syntax to use.

    Primary Keys cannot be disabled since they are supported by a unique index.
    A unique index always must be maintained, so the only way to not enforce the
    Primary Key is to drop the index, which means dropping the constraint.

    -- 
    HTH
    ----------------
    Kalen Delaney
    SQL Server MVP
    www.SolidQualityLearning.com
    "Leida" <Leida@discussions.microsoft.com> wrote in message 
    news:AD81D4EF-060C-41FA-82D0-A223EB41BD9A@microsoft.com...
    > Isn't there a way, other then Enterprise Manager, to disable and / or 
    > enable
    > constraints, in particular primary and foreign keys? I am migrating data
    > daily from one system to SQL and to disable and enable manually is
    > inconvenient and combersome. I looked through BOL and cannot find a direct
    > answer on how to create a process to automatically disable and / or enable
    > constraints.  Thanks. 
    

  • Next message: Sri: "statistics - one more"

    Relevant Pages

    • Constraints: disable / enable constraints issue
      ... Isn't there a way, other then Enterprise Manager, to disable and / or enable ... constraints, in particular primary and foreign keys? ... I am migrating data ...
      (microsoft.public.sqlserver.server)
    • Re: Constraints: disable / enable constraints issue
      ... and the syntax. ... >> constraints, in particular primary and foreign keys? ... > ALTER TABLE tablename NOCHECK CONSTRAINT ALL ...
      (microsoft.public.sqlserver.server)
    • disable foreign keys temporarily?
      ... Please provide me the syntax of "alter table..." ... foreign keys in Accsee database. ...
      (microsoft.public.vb.database)
    • Re: Foreign superkey support
      ... I don't think of constraints as being part of the algebra per se. ... These constraints are on a database variable, ... something like 5-10 foreign keys for the cost of a single domestic key. ...
      (comp.databases.theory)
    • Re: Foreign superkey support
      ... I don't think of constraints as being part of the algebra per se. ... database, and while their enforcement during DML operations is critical, I ... Frankly I think there's too much emphasis on foreign keys. ...
      (comp.databases.theory)