Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ALTER column via sql script and column part of primary key 1

Status
Not open for further replies.

UltraSmooth

Programmer
Oct 28, 2002
97
CA
I'm trying to modify some columns using an sql script. The columns are part of the primary key or indexes of the table. How can I do this with a script, I know I can do it with Enterprise Manager.

When I use the following:

alter table master
alter column [ID] varchar(3);

I get the following error:

Server: Msg 5074, Level 16, State 8, Line 1
The object 'PK_master' is dependent on column 'ID'.
Server: Msg 4922, Level 16, State 1, Line 1
ALTER TABLE ALTER COLUMN ID failed because one or more objects access this column.

I guess I could always drop/disable the keys and recreate them again. Any other way without do maybe force it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top