mssql读取mysql表_获取MSSQL所有数据库名、所有表名、所有字段名

Select

a.Name as Caption, --列名

(CASE WHEN (Select count(*) FROM sysobjects Where

(name in (Select name FROM sysindexes Where (id = a.id)

AND (indid in (Select indid FROM sysindexkeys Where (id = a.id)

AND (colid in (Select colid FROM syscolumns Where (id = a.id)

AND (name = a.name)))))))

AND (xtype = 'PK' ))>0 then 1 else 0 end) as IsPrimaryKeyMember, --主键

b.name as DataType, --数据类型

a.Length as [Size], --长度

(case when a.isnullable=1 then 1 else 0 end) as AllowDBNull, --允许空

isnull(e.text,'') as DefaultValue, --默认值

isnull(g.[value],'' ) AS Description --说明

FROM syscolumns a

LEFT JOIN systypes b ON a.xtype=b.xusertype

INNER JOIN sysobjects d ON a.id=d.id and d.xtype='U' and d.name<> 'dtproperties'

LEFT JOIN syscomments e ON a.cdefault=e.id

LEFT JOIN sys.extended_properties g ON a.id=g.major_id AND a.colid = g.minor_id

Where d.name='Person'

orDER BY a.id,a.colorder

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值