使用SMO重命名数据文件 [英] Use smo to rename datafiles

查看:154
本文介绍了使用SMO重命名数据文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用SMO重命名.NDF .ldf文件的物理.MDF。 <一href="http://sqlforums.windowsitpro.com/web/forum/messageview.aspx?catid=83&threadid=88362&enterthread=y"相对=nofollow>这文章是有益的,但​​我需要使用C#SMO对象。

How can I use SMO to rename the physical .mdf .ndf .ldf files. This article was helpful but I need to use C# SMO Objects.

使用SMO服务器对象,我可以检索数据库,然后可以访问数据文件的对象。每本链接。这些有重,但重命名后,没有什么变化。

Using the SMO Server Object I can retrieve the database, then Get Access to the DataFile objects. Per this link. These have a Rename, however after rename, nothing changes.

推荐答案

嗯,我没有试过,但根据您的第一个环节,你可以分离数据库,重命名磁盘上的文件,然后重新连接数据库。所以,给这一个镜头。

Well, I haven't tried this, but as per your first link, you can detach the database, rename the file on disk and then re-attach the database. So, give that a shot.

在SMO的Server对象有一个分离(..)和附加(..)方法,您可以使用。然后,只需使用File.Move(..)重命名的文件。

The Server object in SMO has a Detach(..) and Attach(..) methods that you can use. Then, just use File.Move(..) to rename the file.

这篇关于使用SMO重命名数据文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆