Created
March 17, 2023 06:56
-
-
Save ecormaksin/336a687667a76b7c0ba9fa5d08e0567c to your computer and use it in GitHub Desktop.
T-SQL SQL Serverでテーブル定義を取得するクエリ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://learn.microsoft.com/ja-jp/sql/relational-databases/tables/view-the-table-definition?view=sql-server-ver16#TsqlProcedure | |
SELECT | |
s.name AS schema_name | |
, t.name AS table_name | |
, c.* | |
, st.name AS [システム型] | |
, ut.name AS [ユーザー定義型] | |
FROM | |
sys.columns AS c | |
INNER JOIN sys.tables AS t ON | |
t.object_id = c.object_id | |
INNER JOIN sys.schemas AS s ON | |
s.schema_id = t.schema_id | |
LEFT OUTER JOIN sys.types AS st ON | |
c.system_type_id = st.system_type_id | |
LEFT OUTER JOIN sys.types AS ut ON | |
c.user_type_id = ut.user_type_id | |
ORDER BY | |
s.name | |
, t.name | |
, c.column_id | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment