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. Adding an Identity Later T-SQL

Adding an Identity Later T-SQL

Scheduled Pinned Locked Moved Database
csharpasp-netdatabasecom
3 Posts 2 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.
  • V Offline
    V Offline
    Vimalsoft Pty Ltd
    wrote on last edited by
    #1

    Good Day All i have a Table with the ID Field that was not an identity Field. This Field has not Duplicates. Now later i want to Change this numeric Field as an Identity Field like this

    --STEP 7 ADD THE IDENTITY BACK IN TABLE MTM_ACTV_STAFF
    ALTER TABLE [New_Jaco].[dbo].[MTM_ACTV_STAFF]
    ALTER COLUMN [ID] IDENTITY(1,1)

    but i get an Error that says

    Msg 156, Level 15, State 1, Line 3
    Incorrect syntax near the keyword 'IDENTITY'.

    Thanks

    Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

    M 1 Reply Last reply
    0
    • V Vimalsoft Pty Ltd

      Good Day All i have a Table with the ID Field that was not an identity Field. This Field has not Duplicates. Now later i want to Change this numeric Field as an Identity Field like this

      --STEP 7 ADD THE IDENTITY BACK IN TABLE MTM_ACTV_STAFF
      ALTER TABLE [New_Jaco].[dbo].[MTM_ACTV_STAFF]
      ALTER COLUMN [ID] IDENTITY(1,1)

      but i get an Error that says

      Msg 156, Level 15, State 1, Line 3
      Incorrect syntax near the keyword 'IDENTITY'.

      Thanks

      Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

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

      A quick guess, I never script these thing I use SSMS, but don't you need a data type in the alter as well as the create.

      ALTER COLUMN [ID] INT IDENTITY(1,1)

      Never underestimate the power of human stupidity RAH

      V 1 Reply Last reply
      0
      • M Mycroft Holmes

        A quick guess, I never script these thing I use SSMS, but don't you need a data type in the alter as well as the create.

        ALTER COLUMN [ID] INT IDENTITY(1,1)

        Never underestimate the power of human stupidity RAH

        V Offline
        V Offline
        Vimalsoft Pty Ltd
        wrote on last edited by
        #3

        does not work , but i found a resolution. here http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/7f24ba5a-b091-4119-9216-1564b61f4aa0/[^]

        Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

        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