how to alter primary key int datatype to uniqueidentifier

  • hi

    help me..

    how to alter primary key int datatype to uniqueidentifier

    Thanks
    Dastagiri.D

  • Drop the PK constraint.

    Add the UID column, add a PK constraint to that.

    Drop the old ID column.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • hi..

    any code.

    i need t-sql query for alter int to uniqueidentifier

    Thanks
    Dastagiri.D

  • Look up ALTER TABLE in books online (web version: http://msdn.microsoft.com/en-us/library/ms190273%28SQL.90%29.aspx)

    ALTER TABLE ... DROP CONSTRAINT ... to remove the pk

    ALTER TABLE ... ADD ... to add a new column

    ALTER TABLE ... DROP ... to drop the old column

    ALTER TABLE ... ADD CONSTRAINT ... to replace the pk constraint.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply