Re: Constraints: disable / enable constraints issue

From: Tom Moreau (tom_at_dont.spam.me.cips.ca)
Date: 10/27/04


Date: Wed, 27 Oct 2004 16:47:02 -0400

You can use ALTER TABLE to disable a foreign key. You cannot disable a
primary key, since it uses a unique index.

-- 
Tom
---------------------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.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.


Relevant Pages

  • A pk is *both* a physical and a logical object.
    ... Primary key is a logical constraint. ... but SQL Server does not allow you to create a unique or primary ... constraints) by indexing is purely *platform dependent*. ... PKs are part of the ANSI SQL standard *for db implementations*. ...
    (comp.databases.theory)
  • Re: Linking a table on Access 2007
    ... indexes and constraints - like a primary key - have each an ... I have build an ODBC connection to the front end DB on the PC that has the ... dbo.tblFEStatus in the SQL Server Express DB that I have an ODBC ...
    (microsoft.public.access.externaldata)
  • Re: SQL Server error when attempting to delete a record
    ... What version of SQL Server have you got? ... recordto be affected and execute this command based on the Primary Key ... Script the table's definition to a file (including constraints, indices, ... of the database, factors like that. ...
    (microsoft.public.sqlserver.server)
  • Re: Disable relationships
    ... ALTER TABLE DISABLE CONSTRAINTS ALL ... We have a table that indicates the people in the SQL Server 2K ... > painful with the current foreign key relationships we have. ...
    (microsoft.public.sqlserver.programming)
  • Re: multiple cascade paths
    ... Obviously, with commit-time validation of constraints, we could get ... But this is a newsgroup on SQL Server, and all data-modelling I do is ... I'd prefer to see all the mutual foreign key ... using a stored proc or trigger to do the cascading. ...
    (comp.databases.ms-sqlserver)

Loading