Re: Changing a primary key data type
From: Dan Guzman (guzmanda_at_nospam-online.sbcglobal.net)
Date: 10/15/04
- Next message: Dan Guzman: "Re: sa privileges and roles"
- Previous message: Ilya Margolin: "Re: Stored procedure dependencies"
- In reply to: Peter B.L. Rasmussen: "Changing a primary key data type"
- Next in thread: Peter B.L. Rasmussen: "Re: Changing a primary key data type"
- Reply: Peter B.L. Rasmussen: "Re: Changing a primary key data type"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 15 Oct 2004 07:23:40 -0500
You can detailed table information, including constraints and indexes, with
sp_help. Then, use your ALTER TABLE to remove the desired constraint. For
example:
EXEC sp_help 'MyTable'
ALTER TABLE MyTable
DROP CONSTRAINT <constraint name here>
Consider explicitly naming the constraint with you add it back. This will
make subsequent schema modifications easier:
ALTER TABLE MyTable
ADD CONSTRAINT PK_MyTable
PRIMARY KEY (MyColumn)
-- Hope this helps. Dan Guzman SQL Server MVP "Peter B.L. Rasmussen" <PeterBLRasmussen@discussions.microsoft.com> wrote in message news:8874FCA5-2FBE-4E0F-BEC9-38417C15C238@microsoft.com... >I need to change the data type for a column that is part of the primary key > of the table from int to nvarchar(15). I will have to get rid of the > primary > key constraint first, bu I can't seem to figure out how to do it. > > The constraint (or whatever it is) was originally created by Microsoft > Access Upgrading Wizard, so I don't know what it has made. > > I know that the name of the object is "aaaaaVarer_PK" > > if I try to drop constraint: > alter table Varer drop constraint aaaaaVarer_PK > I get: 'aaaaaVarer_PK' is not a constraint. > > if I try to drop index: > DROP INDEX Varer.aaaaaVarer_PK > I get: An explicit DROP INDEX is not allowed on index > 'Varer.aaaaaVarer_PK'. It is being used for PRIMARY KEY constraint > enforcement. > > There must exist a PK constraint related to this index. Where do I find > the > name of that constraint? > > in sysobjects aaaaaVarer_PK has xtype=PK, type=K, id=18099105 > > id 18099105 exists in sysconstraints, but all I can see there is that it > is > related to the Varer table >
- Next message: Dan Guzman: "Re: sa privileges and roles"
- Previous message: Ilya Margolin: "Re: Stored procedure dependencies"
- In reply to: Peter B.L. Rasmussen: "Changing a primary key data type"
- Next in thread: Peter B.L. Rasmussen: "Re: Changing a primary key data type"
- Reply: Peter B.L. Rasmussen: "Re: Changing a primary key data type"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|