删除表数据 保持表列名, 但是ID更新.从1开始.
语句怎么写. 假定表为 UserInfo

解决方案 »

  1.   

    --不删除数据,更新现有表的自增列的idselect identity(int,1,1) as id_num,* into #temp from   UserInfoupdate a set a.id=b.id_num from UserInfo a,#temp b where a.id=b.id
      

  2.   


    A truncate table UserInfoB delete from UserInfo
      Dbcc CheckIdent('UserInfo',Reseed,0)
      

  3.   

    都是删除数据
    truncate table UserInfo
    是以后添加的数据,identity字段从1开始
    delete from UserInfo
    是以后添加的数据,identity字段接着删除之前的继续增加