LoginSignup
0
2

More than 5 years have passed since last update.

SQL Server 2008 R2 の データベースを複製する

Posted at

SQL Server 2008 R2のコピーを行う。
同じサーバに別名のデータベースを作ります。

環境

  • Microsoft SQL Server 2008 R2
  • Windows 2003 Foundation

SQL Server Management Studio でのデータベースのコピー

まずは、付属のSQL Server Management Studioを使って試してみる。

GUIのオブジェクトエクスプローラーからデータベースを右クリック→タスク→データベースのコピー

だと、別サーバにコピーするのが前提のようでできなかった。

他の方法を調べてみた

「SQL Server Database Copy Tool」を使う方法
http://www.atmarkit.co.jp/fdotnet/dotnettips/859dbcopytool/dbcopytool.html

スクリプトを使う方法
https://qiita.com/yakumo/items/c495370cf3cc6d50410b

今回は、スクリプトを使う方法を試してみた。

スクリプトの作成方法

https://qiita.com/yakumo/items/c495370cf3cc6d50410b
の通りに進めます

スクリプトの編集

今回は、データはサンプルデータ程度しか必要が無かったのでメモ帳で開いていらないデータを削除。
スクリプトファイルが200Mbytes超え→7Mbytes程度になった。

また、データベース名を新しいデータベース名に置換

スクリプトからのデータベース復元

  • SQL Server Management Studio は開いてサーバに接続しておく
  • エクスプローラから先ほど作成したスクリプトをダブルクリックするとSQL Server Management Studioでスクリプトが開く

  • スクリプトを右クリックして実行

  • エラー出る。 SQL Server Management Studio を再起動するとデータベースやテーブルはできているがデータは移行していない。

  • 調査中

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2