exec sp_configure 'allow updates',1 reconfigure with override
go
alter 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>@colid
update 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
exec sp_configure 'allow updates',1 reconfigure with override
go
alter 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>@colid
update syscolumns set colid=@colid
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