相思资源网 Design By www.200059.com
复制代码 代码如下:
SELECT
TableName = OBJECT_NAME(c.object_id),
ColumnsName = c.name,
Description = ex.value,
ColumnType=t.name,
Length=c.max_length
FROM
sys.columns c
LEFT OUTER JOIN
sys.extended_properties ex
ON
ex.major_id = c.object_id
AND ex.minor_id = c.column_id
AND ex.name = 'MS_Description'
left outer join
systypes t
on c.system_type_id=t.xtype
WHERE
OBJECTPROPERTY(c.object_id, 'IsMsShipped')=0
AND OBJECT_NAME(c.object_id) ='tablename'



1.获取所有数据库名:
Select Name FROM Master..SysDatabases orDER BY Name
2.获取所有表名:
Select Name FROM DatabaseName..SysObjects Where XType='U' orDER BY Name
XType='U':表示所有用户表;
XType='S':表示所有系统表;
3.获取所有字段名:
Select Name FROM SysColumns Where id=Object_Id('TableName')
标签:
表名,字段

相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com

评论“sql根据表名获取字段及对应说明”

暂无sql根据表名获取字段及对应说明的评论...