获取数据库中用户表所有列和列的数据类型

获取数据库中,所有用户表中每一列名和其数据类型。

 

SELECT OBJECT_NAME(c.OBJECT_ID) AS [Table_Name], c.[name] AS [Column_Name] ,t.[name] AS [Data_Type_Name]  
FROM sys.columns AS c  
LEFT JOIN SYSOBJECTS AS s ON (c.[object_id] = s.[id])  
LEFT JOIN sys.types AS t ON (c.[user_type_id]=t.[user_type_id])
WHERE s.xtype = 'U'
Source Code

 

posted @ 2020-01-02 11:42  Insus.NET  阅读(866)  评论(0编辑  收藏  举报