2

AdventureWorksLT2008データベースのAdventureWorksLT2008_old名前.ldf.mdfファイルの名前も変更するにはどうすればよいですか?

からやりたいと思いますsqlcmd。ローカルサーバーです。-Eオプションでやりたいです。グーグルを試しましたが、結果はうまくいきませんでした。誰でも試した方法を提案できますか。

誰でも助けてもらえますか?

4

1 に答える 1

1

a quick google search got this as the top result. All you have to do is to everything from sqlcmd( I am assuming you know how to use sqlcmd..)

-- Replace all MyDBs with the name of the DB you want to change its name
USE [MyDB];
-- Changing Physical names and paths
-- Replace all NewMyDB with the new name you want to set for the DB
-- Replace 'C:\...\NewMyDB.mdf' with full path of new DB file to be used
ALTER DATABASE MyDB MODIFY FILE (NAME = ' MyDB ', FILENAME = 'C:\...\NewMyDB.mdf');
-- Replace 'C:\...\NewMyDB_log.ldf' with full path of new DB log file to be used
ALTER DATABASE MyDB MODIFY FILE (NAME = ' MyDB _log', FILENAME = 'C:\...\NewMyDB_log.ldf');
-- Changing logical names
ALTER DATABASE MyDB MODIFY FILE (NAME = MyDB, NEWNAME = NewMyDB);
ALTER DATABASE MyDB MODIFY FILE (NAME = MyDB _log, NEWNAME = NewMyDB_log);
于 2013-03-31T01:33:20.673 に答える