/////////
/////////////// Result
SELECT c.name as ColumnName, case When t.name ='varchar' OR t.name ='nvarchar' or t.name ='Text' Then 'System.String'
When t.name ='int' Then 'System.Int32'
When t.name ='decimal' Then 'System.Decimal'
When t.name ='float' Then 'System.Decimal'
When t.name ='datetime' OR t.name ='Date' OR t.name ='time' Then 'System.DateTime'
When t.name ='date' Then 'System.Date'
When t.name ='bit' Then 'System.Boolean'
--When
t.name ='Text' Then 'System.Text'
else 'System.' + t.name end AS TypeName FROM sys.columns c INNER JOIN sys.types t ON c.user_type_id = t.user_type_id LEFT OUTER JOIN sys.index_columns ic ON ic.object_id = c.object_id AND ic.column_id = c.column_id LEFT OUTER JOIN sys.indexes i ON ic.object_id = i.object_id AND ic.index_id = i.index_id WHERE c.object_id = ( SELECT type_table_object_id FROM
sys.table_types WHERE name = 'TableName')
/////////////// Result
ColumnName
|
TypeName
|
EmployeeID
|
System.Int32
|
ContactPerson
|
System.String
|
Contact
|
System.String
|
Relationship
|
System.Int32
|
Address
|
System.String
|
Other
|
System.String
|
No comments:
Post a Comment