--------------Table List 불러오기--------------
SELECT
[NAME] AS [테이블명]
FROM SYS.TABLES
--------------Table 별 Column List 불러오기--------------
SELECT
A.[NAME] AS [테이블명],
B.[NAME] AS [컬럼명],
UPPER(TYPE_NAME(B.USER_TYPE_ID)) AS [컬럼타입],
CASE
WHEN (
TYPE_NAME(USER_TYPE_ID) = 'VARCHAR'
OR TYPE_NAME(USER_TYPE_ID) = 'NVARCHAR'
OR TYPE_NAME(USER_TYPE_ID) ='CHAR'
OR TYPE_NAME(USER_TYPE_ID) ='NCHAR'
)
THEN CAST(MAX_LENGTH AS VARCHAR)
WHEN TYPE_NAME(USER_TYPE_ID) = 'DECIMAL'
THEN CAST([PRECISION] AS VARCHAR)+','+CAST(SCALE AS VARCHAR)
ELSE ''
END AS [컬럼크기],
CASE
WHEN IS_NULLABLE = 1 THEN 'Y'
ELSE 'N'
END [NULL 허용여부]
FROM SYS.TABLES AS A
INNER JOIN SYS.COLUMNS AS B
ON A.[OBJECT_ID] = B.[OBJECT_ID]
출처: http://nuricle.tistory.com/entry/MS-SQL-Table-List-%EB%B0%8F-Column-%EC%A0%95%EB%B3%B4-%EB%B6%88%EB%9F%AC%EC%98%A4%EA%B8%B0
음/양 변환 데이타 (0) | 2015.03.20 |
---|---|
MS-SQL Try Catch (0) | 2015.01.15 |
MS-SQL LPAD RPAD 따라하기 (0) | 2015.01.15 |
MS-SQL 자체 암호화 처리 방법 (0) | 2015.01.15 |
Column List (0) | 2014.12.01 |