既存の列を自己増分列に変更

414 ワード

  select   *   into   tmp   from   t   
  //        
  alter   table   t   drop   column   id   
  alter   table   t   add   id   int   identity(1,1)   
  set   identity_insert   t   on   
  insert   into   t(id,col1,col2)   select   id,col1,col2   from   tmp
  //     *,         
  set   identity_insert   t   off   
  drop   table   tmp