欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

SQL SERVER 查询表字段信息SQL脚本

程序员文章站 2024-03-15 17:33:00
...

查询格式:

SELECT
	so.name AS 表名称,
	sc.name AS 字段名,
	st.name AS 数据类型,
	sc.length AS 长度,
	sc.colorder AS 序号
FROM
	syscolumns sc,
	systypes st,
	sysobjects so
WHERE
	st.xtype= sc.xtype 
	AND sc.id = so.id
	AND so.type='U'
	order by so.name,sc.colorder;

查询示例:

SELECT
  'MTNOH_AAA_Resource' AS 数据库名,
	so.name AS 表名称,
	sc.name AS 字段名,
	st.name AS 数据类型,
	sc.length AS 长度,
	sc.colorder AS 序号
FROM
	syscolumns sc,
	systypes st,
	sysobjects so
WHERE
	st.xtype= sc.xtype 
	AND sc.id = so.id
	AND so.type='U'
	order by so.name,sc.colorder;

查询效果:

SQL SERVER 查询表字段信息SQL脚本

相关标签: SQL SERVER