SQL中查询数据表字段名称的查询语句,SQL中查询数据表字段名称的查询语句
【 tulaoshi.com - SQLServer 】
以下为在SQL Server中查看某个表的字段信息的查询语句(以数据库Pubs的jobs表为例)SELECT SysObjects.Name as TableName,
SysColumns.Name as ColumnsName,
SysTypes.Name as DateType,
SysColumns.Length as DateLength,
SysProperties.Value as Remark --列描述
FROM SysObjects,
SysTypes,
SysColumns
LEFT JOIN SysProperties
ON (Syscolumns.Id = Sysproperties.Id AND Syscolumns.Colid = Sysproperties.Smallid)
WHERE (Sysobjects.Xtype ='u' OR Sysobjects.Xtype ='v')
AND Sysobjects.Id = Syscolumns.Id
AND SysTypes.XType = Syscolumns.XType
AND SysTypes.Name < 'sysname'
AND SysObjects.name = 'jobs'
如果需要查询整个数据库的所有表的话,就把最后哪个条件去掉即可。
来源:http://www.tulaoshi.com/n/20160129/1496579.html
看过《SQL中查询数据表字段名称的查询语句》的人还看了以下文章 更多>>