1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
/*
2021 06 16 HJH SELECT NAME, SYSTEM_TYPE_ID FROM SYS.TYPES 아래 내용은 내가 그냥 정한거임... string 35, 40, 41, 99, 167, 175, 231, 239, object 34, 36, 165, 173, 189, 241 datetime 42, 43, 58, 61 double 59, 60, 62, 108, 122 int 48, 52, 56, 106, 127 bool 104 not defined 98,240 */ DECLARE @NameSpace VARCHAR(100) = 'C#에서 사용할 NameSpace명' DECLARE @TableName VARCHAR(100) = '테이블명'
SELECT 'using System;'
UNION ALL
SELECT ''
UNION ALL
SELECT 'namespace ' + @NameSpace
UNION ALL
SELECT '{'
UNION ALL
SELECT CHAR(9) + 'public class ' + @TableName
UNION ALL
SELECT CHAR(9) + '{'
UNION ALL
SELECT
CHAR(9) + CHAR(9)
+ 'public '
+ CASE
WHEN SYSTEM_TYPE_ID IN (35, 40, 41, 99, 167, 175, 231, 239) then 'string '
WHEN SYSTEM_TYPE_ID IN (34, 36, 165/*varbinary*/, 173, 189, 241) then 'object '
WHEN SYSTEM_TYPE_ID IN (42, 43, 58, 61) then 'DateTime '
WHEN SYSTEM_TYPE_ID IN (59, 60, 62, 122) OR (SYSTEM_TYPE_ID = 108 AND SCALE > 0) then 'double '
WHEN SYSTEM_TYPE_ID IN (48, 52, 56, 106, 127) OR (SYSTEM_TYPE_ID = 108 AND SCALE = 0) then 'int '
WHEN SYSTEM_TYPE_ID IN (104) then 'bool '
ELSE NULL END -- NOT DEFINED : 98, 240 등...
+ [NAME]
+ ' { get; set; }'
FROM SYS.COLUMNS COL
WHERE OBJECT_ID = OBJECT_ID(@TableName)
UNION ALL
SELECT CHAR(9) + '}'
UNION ALL
SELECT '}'
|
cs |
'DB > MS-SQL' 카테고리의 다른 글
test (0) | 2023.02.23 |
---|---|
MSSQL 특정 시간으로 복원 (0) | 2021.02.23 |
MSSQL DELETE 복원 (0) | 2021.02.23 |
MSSQL 특정 테이블 스키마 생성 스크립트 (0) | 2021.02.23 |
MSSQL FULL 백업 및 TRANSACTION LOG 백업 프로시저 (0) | 2021.02.23 |