1

我需要从中获取所有表名和列类型sys.columns。我试过这个:

SELECT OBJECT_ID 
FROM   sys.COLUMNS 

OBJECT_ID给出的值而不是确切的名称。

4

2 回答 2

1

您可以使用该object_name()函数从给定的object_id.

您可以加入sys.types视图以获取类型名称:

select c.object_id, object_name(c.object_id), c.name, t.name from sys.columns c
join sys.types t on t.system_type_id = c.system_type_id;
于 2013-07-31T16:56:49.213 回答
1

试试这个我希望它可以帮助

SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID 
ORDER BY schema_name, table_name;
于 2013-07-31T16:59:28.377 回答