以下の内容はhttps://odashinsuke.hatenablog.com/entry/20130630/1372561374より取得しました。


特定のスキーマに属するテーブルを全部消す

最近よく使うのでメモ


'ref' というスキーマに属するテーブルを drop するクエリを ';' 区切りでつなげてます。

declare @sql nvarchar(max) 

select @sql= concat(@sql, N'drop table '
  , [sys].[schemas].[name] collate Japanese_CI_AS, N'.'
  , [sys].[tables].[name] collate Japanese_CI_AS, N';')
from [sys].[tables] inner join [sys].[schemas] on ( 
  [sys].[tables].[schema_id] = [sys].[schemas].[schema_id] 
) 
where [sys].[schemas].[name] = 'ref'

exec (@sql)

concat 使ってるので、SQL Server 2012 以上ですね。環境如何では、collate 指定いらないです。




以上の内容はhttps://odashinsuke.hatenablog.com/entry/20130630/1372561374より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14