例如: 现有一张表TEST(A,B,C) 怎样在A和B列之间插入新列D希望结果:TEST(A,D,B,C)========================================= create table test(a int,b int,c int) insert test select 1,2,3 union select 4,5,6 select * from test go exec sp_configure 'allow updates','1' go reconfigure with override go--添加D列 alter table test add D int go --更新B,C列顺序 update test set d=c --新加 update syscolumns set colid=colid+1 where colid>=2 and id=object_id('test')--更新D列顺序 update syscolumns set colid=2 where name='D' and id=object_id('test')--禁用系统标更新 exec sp_configure 'allow updates','0' go reconfigure with override go update test set d=null select * from testdrop table test
现有一张表TEST(A,B,C)
怎样在A和B列之间插入新列D希望结果:TEST(A,D,B,C)=========================================
create table test(a int,b int,c int)
insert test
select 1,2,3 union select 4,5,6
select * from test
go
exec sp_configure 'allow updates','1'
go
reconfigure with override
go--添加D列
alter table test add D int
go
--更新B,C列顺序
update test set d=c --新加
update syscolumns
set colid=colid+1
where colid>=2 and id=object_id('test')--更新D列顺序
update syscolumns
set colid=2
where name='D' and id=object_id('test')--禁用系统标更新
exec sp_configure 'allow updates','0'
go
reconfigure with override
go
update test set d=null
select * from testdrop table test
http://blog.csdn.net/vivianfdlpw/archive/2005/09/29/492112.aspx
exec sp_configure 'allow updates','1'
reconfigure with override
作用是??我覺得少了好了也可以啊?
1)'非运行时设置'是??
2 )在企业管理器中设置如何實現啊?我沒有試過啊。請您指教啦
select a, b,c, ex as newcolumn from table ?ex是表达式,可以是数据表字段名、函数值,常量等,
newcolumn,新增加的字段名