忘れない内にメモメモ。
SQLServerにて、ビューとトリガーの定義の取得方法です。
もっといいやり方知っている方いらっしゃったら教えてください。m(_ _)m
[ビュー]
USE AdventureWorks GO /* ビューの定義を取得 */ SELECT (schemas.name + '.' + views.name) AS Name ,modules.definition AS Definition FROM sys.views views INNER JOIN sys.objects objects ON views.object_id = objects.object_id INNER JOIN sys.schemas schemas ON objects.schema_id = schemas.schema_id INNER JOIN sys.sql_modules modules ON objects.object_id = modules.object_id ORDER BY Name GO
[トリガー]
USE AdventureWorks GO /* トリガーの定義を取得する */ SELECT (schemas.name + '.' + triggers.name) AS Name ,modules.definition AS Definition FROM sys.triggers triggers INNER JOIN sys.objects objects ON triggers.object_id = objects.object_id INNER JOIN sys.schemas schemas ON objects.schema_id = schemas.schema_id INNER JOIN sys.sql_modules modules ON objects.object_id = modules.object_id ORDER BY Name GO