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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. about identity_insert reset problem

about identity_insert reset problem

Scheduled Pinned Locked Moved Database
questiondatabasehelp
4 Posts 4 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.
  • A Offline
    A Offline
    alexyxj
    wrote on last edited by
    #1

    i use identity_insert for a column in one of my tables. when I first insert 5 rows, this column will show number from 1 to 5 (identity set as 1,1), but when I delete this 5 rows and re-insert this 5 rows, the number get incremented (6-10), how can I reset it and make it still start from 1 ??? can I run any simple query to do that?? thanks.

    D W M 3 Replies Last reply
    0
    • A alexyxj

      i use identity_insert for a column in one of my tables. when I first insert 5 rows, this column will show number from 1 to 5 (identity set as 1,1), but when I delete this 5 rows and re-insert this 5 rows, the number get incremented (6-10), how can I reset it and make it still start from 1 ??? can I run any simple query to do that?? thanks.

      D Offline
      D Offline
      David Mujica
      wrote on last edited by
      #2

      The intent of an identity column is that it uniquely defines a row in a table, FOREVER ! You can always create another row in that table with the exact other values, but it will never be known by an identity value previously assigned. It may be possible to re-assign the identity sequence generator, but don't do it. Have you considered what would happen if another table was referencing your master table with this identity column ?

      1 Reply Last reply
      0
      • A alexyxj

        i use identity_insert for a column in one of my tables. when I first insert 5 rows, this column will show number from 1 to 5 (identity set as 1,1), but when I delete this 5 rows and re-insert this 5 rows, the number get incremented (6-10), how can I reset it and make it still start from 1 ??? can I run any simple query to do that?? thanks.

        W Offline
        W Offline
        Wendelius
        wrote on last edited by
        #3

        For example DBCC CHECKIDENT (Transact-SQL) [^]. However, identity is used to generate surrogate key values so the number generated should always be irrelevant. The database does not quarantee anything but uniqueness.

        The need to optimize rises from a bad design. My articles[^]

        1 Reply Last reply
        0
        • A alexyxj

          i use identity_insert for a column in one of my tables. when I first insert 5 rows, this column will show number from 1 to 5 (identity set as 1,1), but when I delete this 5 rows and re-insert this 5 rows, the number get incremented (6-10), how can I reset it and make it still start from 1 ??? can I run any simple query to do that?? thanks.

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          In case you did not get it - DO NOT CHANGE THE IDENTITY VALUES - this is a basic tennant of relational databases.

          Never underestimate the power of human stupidity RAH

          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