0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

SQL Serverのデータベース間のレコードをコピーする

Posted at

1. はじめに

  • SQL Serverで移行元データベースから移行先データベースへレコードをコピーしたい
  • SQLのSELECT,INSERTで一括で実施したい

2. 開発環境

  • SQL Server 2022 Express

3. 事前準備

  • 移行元データベースに移行先データベースへINSERTする権限があるユーザーを追加する

image.png

image.png

4. SQL実行

  • 移行元データベースに接続して、SELECT, INSERTのSQLを実行する
    • 移行元DB: TEST1、移行先DB: TEST2の場合
insert into
 [TEST2].[dbo].テーブル名
(
 カラム1,
 カラム2,
 カラム3
)
select
 カラム1,
 カラム2,
 カラム3
from [TEST1].[dbo].テーブル名;

5. 参考文献

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?