ALTER TABLE T ALTER COLUMN [ID] INT 只是转换了数据类型,

解决方案 »

  1.   

    create table test(id int identity(1,1),col varchar(10))
    insert test select 5,'a'
    insert test select 'b'
    go
    sp_configure 'allow update',1
    reconfigure with override
    go
    update syscolumns set colstat=0 where colstat=1 and id=object_id('test')
    go
    sp_configure 'allow update',0
    reconfigure with override
      

  2.   

    CREATE TABLE TE
    (
      T_ID INT IDENTITY(10,1),
      T_NAME VARCHAR(20)
    )INSERT TE SELECT 'AA' UNION ALL
              SELECT 'BBB' ALTER TABLE TE
    ADD TEMP_ID INT 
    GO
    UPDATE TE SET TEMP_ID=T_ID
    GO
    ALTER TABLE TE
    DROP COLUMN T_ID 
    GO
    EXEC SP_RENAME 'TE.TEMP_ID','TE_ID','COLUMN'
      

  3.   

    create table test(id int identity(1,1),col varchar(10))
    insert test select 5,'a'
    insert test select 'b'
    go
    sp_configure 'allow update',1
    reconfigure with override
    go
    update syscolumns set colstat=0 where colstat=1 and id=object_id('test')
    go
    sp_configure 'allow update',0
    reconfigure with override
      

  4.   

    我的identity是主键。有很多的constraint,会很复杂的。