Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Add unique column to existing table

Author  Topic 

OldMySQLUser
Constraint Violating Yak Guru

301 Posts

Posted - 2009-01-13 : 07:25:06
How can I add a unique (int) column to an existing SQL Server 2005 table please? The table is archive data which is never written to (if that helps any).

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-13 : 07:32:12
ALTER TABLE History ADD rowID INT IDENTITY(1, 1) PRIMARY KEY NONCLUSTERED


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

OldMySQLUser
Constraint Violating Yak Guru

301 Posts

Posted - 2009-01-13 : 07:40:39
Aha! Many thanks Peso - much appreciated.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-13 : 08:20:18
The PRIMARY KEY [CLUSTERED] option is not mandatory.
It depends on what you are going to use this column for.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -