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. Changing a column to IDENTITY

Changing a column to IDENTITY

Scheduled Pinned Locked Moved Database
databasesql-serversysadminalgorithmstutorial
5 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.
  • G Offline
    G Offline
    garfield185
    wrote on last edited by
    #1

    Hi everybody. SQL Server 2005 I've got a table "Center (ID,Name)", it has some records registered. I need to change the ID field, and make it IDENTITY = true. I have been searching, and only found information about how to add a new identity column to an existing table, but I have to turn an existing field on a table to Identity. I cannot create a new identity field and then delete the old one, because the registered IDs are not sequential... Any ideas? Thanks a lot.

    Time to come clean... Vive y deja vivir / Live and let live Javier

    N 1 Reply Last reply
    0
    • G garfield185

      Hi everybody. SQL Server 2005 I've got a table "Center (ID,Name)", it has some records registered. I need to change the ID field, and make it IDENTITY = true. I have been searching, and only found information about how to add a new identity column to an existing table, but I have to turn an existing field on a table to Identity. I cannot create a new identity field and then delete the old one, because the registered IDs are not sequential... Any ideas? Thanks a lot.

      Time to come clean... Vive y deja vivir / Live and let live Javier

      N Offline
      N Offline
      Niladri_Biswas
      wrote on last edited by
      #2

      Follow the steps 1)Go to the design view of your table 2)Select ID Column 3) In the down, you will find Column Properties 4)In that you will find Identity Specification whose first property is Identity Specification. The default will be set to "No". Change that to yes. 5)Save the table. Hope this helps :)

      Niladri Biswas

      G 1 Reply Last reply
      0
      • N Niladri_Biswas

        Follow the steps 1)Go to the design view of your table 2)Select ID Column 3) In the down, you will find Column Properties 4)In that you will find Identity Specification whose first property is Identity Specification. The default will be set to "No". Change that to yes. 5)Save the table. Hope this helps :)

        Niladri Biswas

        G Offline
        G Offline
        garfield185
        wrote on last edited by
        #3

        Thanks Niladri, but I meant how to do it in SQL language...

        W N 2 Replies Last reply
        0
        • G garfield185

          Thanks Niladri, but I meant how to do it in SQL language...

          W Offline
          W Offline
          WoutL
          wrote on last edited by
          #4

          Follow the steps 1)Go to the design view of your table 2)Select ID Column 3) In the down, you will find Column Properties 4)In that you will find Identity Specification whose first property is Identity Specification. The default will be set to "No". Change that to yes. 5)Click on "save change script" 6) Save the script to a file or copy it to the clipboard.

          Wout Louwers

          1 Reply Last reply
          0
          • G garfield185

            Thanks Niladri, but I meant how to do it in SQL language...

            N Offline
            N Offline
            Niladri_Biswas
            wrote on last edited by
            #5

            This may help a) http://stackoverflow.com/questions/1049210/adding-an-identity-to-an-existing-column-sql-server[^] b) http://www.mssqltips.com/tip.asp?tip=1397[^] :)

            Niladri Biswas

            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