Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2004
    Location
    Kuala Lumpur
    Posts
    38

    Question Unanswered: alter indentity field

    Hi Guys,
    I'm using SQL server 2000.

    How do I alter column/field from type int (with Identity = Yes Not For Replication) to just normail int field. No more identity. I want it to be done using SQL script( sql query analyzer).

    Please help me on this, thx

    Regards,
    Shaffiq

  2. #2
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    Quote Originally Posted by man_at_work22
    Hi Guys,
    I'm using SQL server 2000.

    How do I alter column/field from type int (with Identity = Yes Not For Replication) to just normail int field. No more identity. I want it to be done using SQL script( sql query analyzer).

    Please help me on this, thx

    Regards,
    Shaffiq
    Code:
    alter table table_name
    alter column column_Name int not null
    that should solve your problem.
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  3. #3
    Join Date
    Oct 2004
    Location
    Kuala Lumpur
    Posts
    38
    Hi Enigma,
    I'd tried it before but it not work. Even query analyzer return success message "The command(s) completed successfully." but when I open the table it still the same. And the identity field still ON

    Regards,
    Shaffiq

  4. #4
    Join Date
    Jun 2003
    Posts
    269

    Thumbs up

    do alteration in Enterprise Manager( dont save it) and click on 'save change script'(3 rd button from second row).copy and run that script in query analyser
    I love cursor,though I never use it.Cos' I dont want to misuse it.
    ----------------------------------------------

    ----cheers
    ----http://mallier.blogspot.com

  5. #5
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    or

    Alter Table MyTable ADD NewColumn int
    GO
    UPDATE MyTAble SET NewColumn = OldColumn
    GO
    ALTER TABLE MyTable DROP COLUMN MyCOlumn
    GO
    sp_rename 'MyTable.NewColumn','OldColumn',COLUMN
    If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry. Earnest Hemingway, A Farewell To Arms.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •