--在指定字段后插入字段exec sp_configure 'allow updates',1 reconfigure with override goalter table 表 add id int --添加字段 go--处理字段位置 declare @colid int select @colid=colid from syscolumns where id=object_id('你要修改的表名') and name='字段名' --在该字段后插入if @colid is null set @colid=1 update syscolumns set colid=colid+1 where id=object_id('你要修改的表名') and colid>@colidupdate syscolumns set colid=@colid+1 where id=object_id('你要修改的表名') and colid=( select max(colid) from syscolumns where id=object_id('你要修改的表名')) go exec sp_configure 'allow updates',0 reconfigure with override
goalter table 表 add id int --添加字段
go--处理字段位置
declare @colid int
select @colid=colid from syscolumns
where id=object_id('你要修改的表名') and name='字段名' --在该字段后插入if @colid is null set @colid=1
update syscolumns set colid=colid+1
where id=object_id('你要修改的表名') and colid>@colidupdate syscolumns set colid=@colid+1
where id=object_id('你要修改的表名') and colid=(
select max(colid) from syscolumns
where id=object_id('你要修改的表名'))
go
exec sp_configure 'allow updates',0 reconfigure with override