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;
查询效果: