バックアップ元と先でカウント一致するかの確認クエリ
これもちょいちょい使うのでメモメモ。
・まずはBKUPを取得
select * into バックアップ先テーブル名
from バックアップ元テーブル名 (nolock);
・BKUP取得後、コピー先とコピー元で件数一致を確認する
select 'テーブル名' as 'table_name'
(select count(*) from バックアップ元テーブル名) as 'moto'
(select count(*) from バックアップ先テーブル名) as 'copy',
( select case when (select count(*) from バックアップ元テーブル名)
= (select count(*) from バックアップ先テーブル名)
then 'OK' else 'NG' end ) as '比較結果'
バックアップテーブルするよね