日期:2014-05-18  浏览次数:20462 次

如何转移SQL SERVER数据表的字段描述
数据库转移到另一台服务器后各表中的字段描述都没有了
有什么办法可以把字段描述也导过来吗

------解决方案--------------------
select a.value as '描述 '
from sysproperties a
inner join syscolumns b on a.id=b.id and a.smallid=b.colid
inner join sysobjects c on a.id=c.id
where c.id = object_id( '表名 ') and b.name= '字段名 '
------解决方案--------------------
两台服务器的数据库平台若都是SQL Server的话,只要作备份再还原,或者先分离后附加,都可以保留原来的字段描述的。
------解决方案--------------------
修改系统表的字段值之前执行:
sp_configure @configname = 'allow updates ', @configvalue = '1 '
RECONFIGURE WITH OVERRIDE
GO

将源数据库中的sysproperties表dts到目的数据库(需要改目的表名字,例如:sysproperties_temp),再update目的数据库的sysproperties表:

update sysproperties
set value=b.value
from sysproperties a join sysproperties_temp b
on a.id=b.id and a.type=b.type and a.smallid=b.smallid and a.name=b.name

go
最后再执行:
sp_configure @configname = 'allow updates ', @configvalue = '0 '
RECONFIGURE WITH OVERRIDE
GO