Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Auto increment

Auto increment

Scheduled Pinned Locked Moved Database
tutorialquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mimimimilaw
    wrote on last edited by
    #1

    I am using auto increment for the primary key in a table. For example, table - (userID, UserName). Now the auto increment of last userId = 10. If I would like to insert a userId = 111, I found that the next auto increment userId must be in 112, but it is not 11. Is there any setting to change back the UserId to 11? Thanks!:)

    R S 3 Replies Last reply
    0
    • M mimimimilaw

      I am using auto increment for the primary key in a table. For example, table - (userID, UserName). Now the auto increment of last userId = 10. If I would like to insert a userId = 111, I found that the next auto increment userId must be in 112, but it is not 11. Is there any setting to change back the UserId to 11? Thanks!:)

      R Offline
      R Offline
      Rami Said Abd Alhalim
      wrote on last edited by
      #2

      hi mimimimilaw you must go to design table ,Set Identity Seed = 10 for column auto increment

      M 1 Reply Last reply
      0
      • R Rami Said Abd Alhalim

        hi mimimimilaw you must go to design table ,Set Identity Seed = 10 for column auto increment

        M Offline
        M Offline
        mimimimilaw
        wrote on last edited by
        #3

        It maybe 10, 20, 45 or any number. How can I using mssql statement to do this?:)

        R 1 Reply Last reply
        0
        • M mimimimilaw

          I am using auto increment for the primary key in a table. For example, table - (userID, UserName). Now the auto increment of last userId = 10. If I would like to insert a userId = 111, I found that the next auto increment userId must be in 112, but it is not 11. Is there any setting to change back the UserId to 11? Thanks!:)

          S Offline
          S Offline
          Senu Gandhi
          wrote on last edited by
          #4

          Hi, Try this DBCC CHECKIDENT ('tablename',RESEED,110) If u execute the above statement then the next number will be 111. But you cannot set it back to 10, because already 111 exists which is greater than 10. May I know the situation why you need the userid to be 111? Senthil

          1 Reply Last reply
          0
          • M mimimimilaw

            It maybe 10, 20, 45 or any number. How can I using mssql statement to do this?:)

            R Offline
            R Offline
            Rami Said Abd Alhalim
            wrote on last edited by
            #5

            Hi mimimimilaw You can use this statment CHECKIDENT ('tablename',RESEED,10) best Regard Rami Abd Alhalim

            1 Reply Last reply
            0
            • M mimimimilaw

              I am using auto increment for the primary key in a table. For example, table - (userID, UserName). Now the auto increment of last userId = 10. If I would like to insert a userId = 111, I found that the next auto increment userId must be in 112, but it is not 11. Is there any setting to change back the UserId to 11? Thanks!:)

              R Offline
              R Offline
              Rami Said Abd Alhalim
              wrote on last edited by
              #6

              If you need anything i am ready RAmi

              M 1 Reply Last reply
              0
              • R Rami Said Abd Alhalim

                If you need anything i am ready RAmi

                M Offline
                M Offline
                mimimimilaw
                wrote on last edited by
                #7

                Thanks All, I try to do what I want in other methods.;)

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups