By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

AutoNumber

100+
P: 114
Guys, recently i have transferred by Access database to sql server 2000 n in a process of upgrading the application too. i m using VB6. well i had tables whose id was an "AutoNumber" in ms access. now when it is converted to sql server it is of integer data type. I just wanna know that is there a data type like the AutoNumber in SQL server too. Does the Uniqueidentifier data type in sql server have the same function as the autonumber in ms access? Or else what is the standard followed to achieve such a task (to generate a unique id for each rows in a table automatically)
Feb 19 '08 #1
Share this Question
Share on Google+
6 Replies


debasisdas
Expert 5K+
P: 8,127
1.before inserting the record findout the count.
2.increment that value by 1 and use for the next row.
Feb 19 '08 #2

100+
P: 114
1.before inserting the record findout the count.
2.increment that value by 1 and use for the next row.
yes dude, thats a gud idea but r u sure this is da standard that u all follow? Plus do u mean 2 say there is no alternatives other than this?
Feb 19 '08 #3

ck9663
Expert 2.5K+
P: 2,878
Try the IDENTITY data type.

Again, it assures uniqueness, not sequence. If you delete a row, that value of your IDENTITY field will not be reuse.

-- CK
Feb 19 '08 #4

100+
P: 114
Try the IDENTITY data type.

Again, it assures uniqueness, not sequence. If you delete a row, that value of your IDENTITY field will not be reuse.

-- CK
thank u dude, i recently came across this but i must say since my table is already with data i cannot create a new table. So, in this case i cannot find the type IDENTITY in the data type column when i try to change the table properties. What does it mean?
Feb 20 '08 #5

ck9663
Expert 2.5K+
P: 2,878
If you can not recreate the table, you can insert a new column of int data type. At the bottom part of the window, change the Identity to "Yes". The seed is the first value that it will use. The increment is how do you want this Autonumber to increment (by 1s, 2s, etc).

-- CK
Feb 20 '08 #6

100+
P: 114
If you can not recreate the table, you can insert a new column of int data type. At the bottom part of the window, change the Identity to "Yes". The seed is the first value that it will use. The increment is how do you want this Autonumber to increment (by 1s, 2s, etc).

-- CK
Thanks guys, u all have been a gr8 help 2 me. well i got the clue n succeded. thanks once again
Feb 20 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.