在批量的修改表名和列名的时候,需要更新系统表。需要对其进行配置。
测试用例:
----
--启用对系统目录的特殊更新
USE master
sp_configure 'allow updates',1
GO
RECONFIGURE WITH OVERRIDE
GO
use code_tmp
update sysobjects
set name = rtrim(a.英文名称)
from code_tmp.dbo.表名对照$ as a inner join
sysobjects b
on b.name = rtrim(a.代码表)
where b.xtype = 'u'
select * from syscolumns where id in (
select id from sysobjects where xtype = 'u')
select * from dbo.Drainage_Type
--禁用对系统目录的特殊更新
USE master
GO
sp_configure 'allow updates', 0
GO
RECONFIGURE WITH OVERRIDE
GO
----
select * from dbo.字段对照表$
select * from syscolumns where id in (select id from sysobjects where xtype = 'u')
--启用对系统目录的特殊更新
USE master
sp_configure 'allow updates',1
GO
RECONFIGURE WITH OVERRIDE
GO
use code_tmp
update syscolumns
set name =rtrim(a.英文名)
from code_tmp.dbo.字段对照表$ as a inner join
syscolumns as b
on rtrim(a.字段名)=b.name
where b.id in(select id from sysobjects where xtype = 'u')
--禁用对系统目录的特殊更新
USE master
GO
sp_configure 'allow updates', 0
GO
RECONFIGURE WITH OVERRIDE
GO