/*当一个栏位被删除后,重新建立后,其位置不在原来的地方,如果想恢复该栏位在表中的出现的顺序,需要更改栏位在syscolumns的colid值,其具体步骤如下:*/ create table test_column(a char(1) null,b char(2) null,c char(1) null,d char(2)null)--栏位被删除前的顺序 select * from test_column alter table test_column drop column c--栏位被删除后的顺序select * from test_column alter table test_column add c varchar(1) null--栏位被添加后的顺序 select * from test_column--更改栏位的顺序:sp_configure 'allow updates','1' go reconfigure with override update syscolumns set colid=colid+1 where colid>3 and id=object_id('test_column') update syscolumns set colid=3 where name='c' and id=object_id('test_column') sp_configure 'allow updates','0' go reconfigure with override go
select * from test_column
alter table test_column drop column c--栏位被删除后的顺序select * from test_column
alter table test_column add c varchar(1) null--栏位被添加后的顺序
select * from test_column--更改栏位的顺序:sp_configure 'allow updates','1'
go
reconfigure with override update syscolumns set colid=colid+1 where colid>3 and id=object_id('test_column')
update syscolumns set colid=3 where name='c' and id=object_id('test_column')
sp_configure 'allow updates','0'
go
reconfigure with override
go