SQLserver 查询某个表的字段及字段属性
2024-09-25 21:40:33
SELECT
C.name as [字段名],T.name as [字段类型]
,convert(bit,C.IsNullable) as [可否为空]
,convert(bit,case when exists(SELECT 1 FROM sysobjects where xtype='PK' and parent_obj=c.id and name in (
SELECT name FROM sysindexes WHERE indid in(
SELECT indid FROM sysindexkeys WHERE id = c.id AND colid=c.colid))) then 1 else 0 end)
as [是否主键]
,convert(bit,COLUMNPROPERTY(c.id,c.name,'IsIdentity')) as [自动增长]
,C.Length as [占用字节]
,COLUMNPROPERTY(C.id,C.name,'PRECISION') as [长度]
,isnull(COLUMNPROPERTY(c.id,c.name,'Scale'),0) as [小数位数]
,ISNULL(CM.text,'') as [默认值]
,isnull(ETP.value,'') AS [字段描述]
--,ROW_NUMBER() OVER (ORDER BY C.name) AS [Row]
FROM syscolumns C
INNER JOIN systypes T ON C.xusertype = T.xusertype
left JOIN sys.extended_properties ETP ON ETP.major_id = c.id AND ETP.minor_id = C.colid AND ETP.name ='MS_Description'
left join syscomments CM on C.cdefault=CM.id
WHERE C.id = object_id('Sys_Member')
最新文章
- swift-懒加载
- clip 属性剪裁绝对定位元素
- wpf 后台绘制圆弧
- NSString 字符串替换
- glusterFS的常用命令 (转)
- http请求利器: 今天配置出了RESTClient,用MAVEN构建了UI运行包
- 松下蓄电池与UPS使用和维护
- margin系列之百分比
- Palindrome - URAL - 1297(求回文串)
- js的兼容性问题
- 第19讲- UI组件之_Button、checkbox、radio
- ThreadPoolExecutor详解
- java和.net的类比
- Intellj Idea使用tomcat部署不成功,死活也找不到解决办法的看这里
- java 表现层:jsp、freemarker、velocity
- POJ1741Tree [点分治]【学习笔记】
- LeetCode算法题-Longest Continuous Increasing Subsequence(Java实现)
- 3.Qt GUI中一些操作记录
- foreach Transform 同时chils.setParent引起的bug
- MemSQL与MySQL不兼容问题总结
热门文章
- layui 数据表格自带的导出Excel,身份证等E+/000问题解决
- Java中的大数值使用
- web自动化 -- 浏览器窗口切换
- 贪心法-------Saruman's army
- Python while 中简单的语句组
- PHP restore_error_handler() 函数
- PHP rmdir() 函数
- RectTransform的localPosition与anchoredPosition(3D)的区别
- Use SQL to Query Data from CDS and Dynamics 365 CE
- SSRS - 请求因 HTTP 状态 401 失败: Unauthorized。