LoginSignup
1
1

More than 3 years have passed since last update.

[備忘録]テーブル・ビュー一括削除の手間を省く。

Posted at
SELECT 'DROP TABLE [' + SCHEMA_NAME(schema_id) + '].[' + name +'];'
FROM sys.tables
UNION ALL 
SELECT 'DROP VIEW [' + SCHEMA_NAME(schema_id) + '].[' + name +'];'
FROM sys.views
ORDER BY 1;

結果をコピーしてクエリエディタに貼り付け、実行する。
残すテーブルがあれば適宜選別する。

参考

https://ameblo.jp/msrogw/entry-10557284547.html
https://blog.sqlauthority.com/2009/06/17/sql-server-list-schema-name-and-table-name-for-database/

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