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 2000 Forums
 SQL Server Development (2000)
 Adding IDENTITY Constraint to Existing Column

Author  Topic 

scelamko
Constraint Violating Yak Guru

309 Posts

Posted - 2005-05-06 : 14:13:56
Guys,
I am trying to add to a identity constraint to an existing column using
alter table xyz alter column [id] int identity(1, 1) not null

But it doesnt seem to work, I can get it to work from EnterprIse Manager though

Any suggestions/inputs would be helpful indeed.

Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-05-06 : 16:29:59
You can't use ALTER TABLE to modify a column to become an identity. Do it in Enterprise Manager but before saving, click the button to save the change script. Notice the code. It requires a temp table to do the work. Let us know if you need some assistance understanding the code that EM will be using. It's pretty much the same code that you'd have to write inside Query Analyzer on your own.

Tara
Go to Top of Page
   

- Advertisement -