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
 Site Related Forums
 Article Discussion
 Auto-incrementing a field

Author  Topic 

llzamboni
Starting Member

5 Posts

Posted - 2006-11-09 : 17:02:12
I am porting a database from Informix to SQL Server 2000. Several fields in the informix database are specified as SERIAL, which means that they auto-increment auto-magically if you insert a 0 into them. Well...I was looking for an equivalent in SQL Server 2000, and thought I had found it in the IDENTITY column concept.

With further investigation into IDENTITY columns, however, I discovered that only one column per table can be given the IDENTITY property. Why is this? Is there a way around that? If not, is there another way to achieve this feature in SQL Server 2000? If not, any suggestions on how I can do it?

Thanks!

Lisa

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-11-09 : 17:04:11
only one column per table can be set as identity.

you can also achieve this behavior with after insert triggers.



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

llzamboni
Starting Member

5 Posts

Posted - 2006-11-09 : 17:12:05
Could you elaborate on how an after insert trigger might look?
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-11-09 : 17:51:54
This discussion seems to have been continued in the cross posted version :)
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=74721&

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -