Re: Alter table help

From: Louis Davidson (dr_dontspamme_sql_at_hotmail.com)
Date: 05/06/04


Date: Thu, 6 May 2004 10:00:28 -0500

And don't forget the most important thing once you have dropped the
constraint, and possibly the column:

alter table table_name add constraint constraint_name primary key
(different_column_name)

:)

-- 
----------------------------------------------------------------------------
Louis Davidson (drsql@hotmail.com)
Compass Technology Management
Pro SQL Server 2000 Database Design
http://www.apress.com/book/bookDisplay.html?bID=266
Note: Please reply to the newsgroups only unless you are
interested in consulting services.  All other replies will be ignored :)
"Adam Machanic" <amachanic@air-worldwide.nospamallowed.com> wrote in message
news:e5TtTM3MEHA.3988@TK2MSFTNGP09.phx.gbl...
> If by "get rid of it" you mean the constraint:
>
> ALTER TABLE table_name DROP CONSTRAINT constraint_name
>
> or if you mean the column itself (assuming it's not a compound key):
>
> ALTER TABLE table_name DROP COLUMN column_name
>
>
> "Tom Pennington" <NONEt2pennington@comcast.net> wrote in message
> news:%23W6IzH3MEHA.2488@TK2MSFTNGP10.phx.gbl...
> > Okay, I'm trying to modify a tables primary key, actually, I'm trying to
> get
> > rid of it.  According to everything I've read, this is the correct
syntax,
> > but it won't work.
> >
> > I'm using the following statement:  ALTER TABLE table_name DROP PRIMARY
> KEY;
> >
> > Any ideas?
> >
> > Tom
> >
> >
>
>


Relevant Pages

  • SQL Server confused about primary keys. So am I.
    ... We are generating a script to convert a client's database to Sql ... ALTER TABLE dbo.Categories ADD ... CONSTRAINT PK_Categories PRIMARY KEY CLUSTERED ...
    (microsoft.public.sqlserver.server)
  • Re: Drop Primary Key with SQL/VBA
    ... >> Syntax error in ALTER TABLE statement. ... > Do you want to drop the Primary Key constraint on a field..... ... > CREATE TABLE tblShipping ...
    (microsoft.public.access.queries)
  • Re: Database design question
    ... say we have document and we need to specify permissions to the ... Is there anyway we can have constraint like ... alter table DocumentPermission ... You also need a primary key for DocumentPermission. ...
    (comp.databases.theory)
  • Re: unknown symbol in ER diagram
    ... main_ID INTEGER NOT NULL PRIMARY KEY ... CONSTRAINT fk__sub1 FOREIGN KEY ... REFERENCES Main ... ALTER TABLE Sub1 ADD CONSTRAINT ch__sub1 ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Is this legal SQL ? Left join dbo.table on filed1=filed2 and filed3 = @memvar
    ... [atbID] ... ALTER TABLE.WITH NOCHECK ADD ... CONSTRAINT PRIMARY KEY CLUSTERED ... CONSTRAINT FOREIGN KEY ...
    (microsoft.public.sqlserver.programming)