问题
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.
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.
回答1:
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.
The Server object in SMO has a Detach(..) and Attach(..) methods that you can use. Then, just use File.Move(..) to rename the file.
来源:https://stackoverflow.com/questions/425296/use-smo-to-rename-datafiles