SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Alter table column to primary key column
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cplusplus
Constraint Violating Yak Guru

481 Posts

Posted - 06/12/2012 :  17:47:25  Show Profile  Reply with Quote
How can i make the following column as primary key column via alter table alter column statement?

[ActivityID] [int] IDENTITY(1,1) NOT NULL



ALTER TABLE Tab_workflows ALTER COLUMN activityid [int] IDENTITY(1,1) NOT NULL


Thanks a lot for the helpful info.

robvolk
Most Valuable Yak

USA
15559 Posts

Posted - 06/12/2012 :  18:19:41  Show Profile  Visit robvolk's Homepage  Reply with Quote
ALTER TABLE Tab_workflows ADD CONSTRAINT PK_Tab_workflows PRIMARY KEY(ActivityID)
Go to Top of Page

cplusplus
Constraint Violating Yak Guru

481 Posts

Posted - 06/13/2012 :  06:58:54  Show Profile  Reply with Quote
Thanks worked perfectly fine.


Edited by - cplusplus on 06/13/2012 07:06:03
Go to Top of Page

prett
Posting Yak Master

USA
161 Posts

Posted - 06/13/2012 :  07:18:15  Show Profile  Reply with Quote
To create a PRIMARY KEY constraint on the "[ActivityID] column when the table is already created, use the following query:
ALTER TABLE 'table name' ADD PRIMARY KEY (column name);
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000