SnowConvert AI - SQL Server

The first step for migration is getting the code that you need to migrate. There are many ways to extract the code from your database. We recommend that you use SQL Server Management Studio (SSMS). We also provide an alternative for MacOS and Linux environments.

前提条件

  • SQLServer データベースのあるサーバーへのアクセス権。

Extraction through SQL Server Management Studio (SSMS)

SQL Server Management Studio(SSMS)はWindowsでのみ利用可能です。Mac OS、Linuxについては次のセクションで説明します。

  1. SSMS を開きます。

  2. 必要なデータベースを表示できる認証情報を使用して、必要なサーバーとサーバーインスタンスに接続します。

  3. SSMS のメインウィンドウで、 Object Explorer を開きます。

  4. Object Explorerペインで、 Databases を展開します。

  5. 目的のデータベースを右クリックし、Tasks -> Generate Scripts …を選択します。

ステップ1

  1. Generate ScriptsダイアログのIntroductionページが表示された場合は、 Next をクリックします。そうでない場合は、次のステップに進みます。

ステップ2

  1. Generate ScriptsダイアログのChoose Objectsページ:

  • Select specific database objects ラジオボタンを選択し、表示された Usersを除く(EXCEPT Users) すべてのデータベースオブジェクトタイプの チェックボックスチェック を入れます(注意(NOTE): 提示されるデータベースオブジェクトタイプのリストは、選択したデータベースに存在するデータベースオブジェクトによります。したがって、データベースオブジェクトタイプのリストは表示が異なる可能性があります。Usersを除くすべてのデータベースオブジェクトタイプ(EXCEPT Users)を選択してください)。

  • Next をクリックします。

ステップ3

  1. Generate ScriptsダイアログのSet Scripting Optionsページ:

  • Save as script file ボタンと One script file per object をクリックします。

ステップ4

  • Advanced ボタンをクリックします。

  • Advanced Scripting Optionsダイアログボックスで、確実に次のオプションが指示どおりに設定され、他のすべてのオプションがデフォルトのままであるようにしてください。

ステップ5

セクション

設定

一般

Include System Constraint names

True

empty

Script Extended Properties

True

Table/View Options

Script Indexes

True

-

Script Triggers

True

  • 完了したら OK をクリックして、Generate ScriptsダイアログのSet Scripting Optionsウィンドウに戻ります。

  • Save as script file ラジオボタンを選択します。

  • File name:フィールドの右側にある省略記号 (...)をクリックします。

  • Navigate to a suitable location, enter a descriptive value in the File Name: field (for example, <server_name>_<instance_name>_<database_name>), and click Save.

  • ANSI text ラジオボタンを選択します。

  • Nextをクリックします。

  1. On the Summary page of the Generate Scripts dialog, confirm the settings are correct and click Next > when ready to start the extraction (that is, the extraction will commence when you click Next >). The Save Scripts page will appear and will show the extraction progress.

ステップ6

  1. Generate Scriptsダイアログボックス(表示されません)のSave Scriptsページで、すべての結果が成功したことを確認し、Finish をクリックします。

  2. 必要なデータベースごとに手順5~10を繰り返します(それぞれ異なるファイル名を使用します)。すべてのデータベースが正常に抽出されたら、次のステップに進みます。

  3. さらなる分析用に結果のファイルをSnowflakeに送信します。

結果をパッケージ化する

抽出処理が終わったら、結果を圧縮して送信します。

テーブルサイジングレポート

  1. オプションA:スコープ内のすべてのデータベースについて、データベースを右クリックし、Reports > Standard Reports > Disk Usage By Tableを選択します。レポートが生成されますので、レポートを右クリックし、Excelとしてエクスポートします。

ステップ6

  1. オプションB:以下のスクリプトを実行します。

USE <DB_NAME>;
SELECT
 t.NAME AS TableName,
 s.NAME AS SchemaName,
 SUM(a.total_pages) * 8 / 1024 AS TotalSpaceMB,
 SUM(a.used_pages) * 8 / 1024 AS UsedSpaceMB,
 (SUM(a.total_pages) - SUM(a.used_pages)) * 8 / 1024 AS
UnusedSpaceMB
FROM
 sys.tables t
INNER JOIN
 sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN
 sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id =
p.index_id
INNER JOIN
 sys.allocation_units a ON p.partition_id = a.container_id
LEFT OUTER JOIN
 sys.schemas s ON t.schema_id = s.schema_id
GROUP BY
 t.NAME, s.NAME, p.Rows
ORDER BY
 TotalSpaceMB DESC;