AutoNumber

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raaman rai
    New Member
    • Oct 2007
    • 114

    AutoNumber

    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 Uniqueidentifie r 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)
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    1.before inserting the record findout the count.
    2.increment that value by 1 and use for the next row.

    Comment

    • raaman rai
      New Member
      • Oct 2007
      • 114

      #3
      Originally posted by debasisdas
      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?

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4
        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

        Comment

        • raaman rai
          New Member
          • Oct 2007
          • 114

          #5
          Originally posted by ck9663
          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?

          Comment

          • ck9663
            Recognized Expert Specialist
            • Jun 2007
            • 2878

            #6
            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

            Comment

            • raaman rai
              New Member
              • Oct 2007
              • 114

              #7
              Originally posted by ck9663
              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

              Comment

              Working...