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
 Express Edition and Compact Edition (2005)
 multiple autonumbering columns

Author  Topic 

sinjin67
Yak Posting Veteran

53 Posts

Posted - 2008-01-10 : 17:03:44
Greetings All,

I am moving from Foxpro to SQL. I am little confused
about one aspect dealing with multiple autonumbering
columns.

In foxpro it will allow you to set your fields to "autonumber"
so you can achieve having 3 or 4 fields for example with unique
numbers, depending on the application function.

When I try to do this in SQL I can setup my first identity
and PK and it autonumbers just fine, when I try to setup
a second autonumber column with a unique I cant seem to
get control of the identity to set the starting seed, Unless
I select that column in the identity to yes, but it seems to
disable the the first identity column I setup.

Can anyone tell what I missed or doing wrong ?

One last note, I am still using the Studio Manager
Still learning the programming portion..

Thanks

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2008-01-10 : 17:15:02
You can only have one identity column per table in SQL Server.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

sinjin67
Yak Posting Veteran

53 Posts

Posted - 2008-01-10 : 17:20:43
If thats the case, can I create a stored procedure or a trigger
to grab the next number from a seperate table ?

Does anyone maybe have an example of doing this ?
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2008-01-10 : 17:29:19
You can. Not sure why you need multiple identity columns in same table..

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

sinjin67
Yak Posting Veteran

53 Posts

Posted - 2008-01-10 : 17:41:48
Its been a real challange from the foxpro way to
the sql way. I am trying to recreate the original
application under sql and it was designed this way.

Thanks
Go to Top of Page
   

- Advertisement -