全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
获取MSSQL表结构中字段的备注、主键等信息?12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182831、MSSQL2000SELECT表名 = case when a.colorder=1 then else end,表说明 = case when a.colorder=1 then isnull(f.value,) else end,字段序号 = a.colorder,字段名 = ,标识 = case when COLUMNPROPERTY( a.id,,IsIdentity)=1 then else end,主键 = case when exists(SELECT 1 FROM sysobjects where xtype=PK and parent_obj=a.id and name in (SELECT name FROM sysindexes WHERE indid in(SELECT indid FROM sysindexkeys WHERE id = a.id AND colid=a.colid) then else end,类型 = ,占用字节数 = a.length,长度 = COLUMNPROPERTY(a.id,,PRECISION),小数位数 = isnull(COLUMNPROPERTY(a.id,,Scale),0),允许空 = case when a.isnullable=1 then else end,默认值 = isnull(e.text,),字段说明 = isnull(g.value,)FROMsyscolumns aleft joinsystypes b ona.xusertype=b.xusertypeinner joinsysobjects d ona.id=d.id and d.xtype=U and dtpropertiesleft joinsyscomments e ona.cdefault=e.idleft joinsysproperties g ona.id=g.id and a.colid=g.smallid left joinsysproperties f ond.id=f.id and f.smallid=0=FI_dept -如果只查询指定表,加上此条件order bya.id,a.colorder2、MSSQL2005use test-數據庫go-2005實現字段屬性統計(2000里的系統表sysproperties描述表、字段不存在,2005里用sys.extended_properties視圖替代)select表名=c.Name,表说明=isnull(f.value,),列名=a.Name,列序號=a.Column_id,標識=case when is_identity=1 then else end,主鍵=case when exists(select 1 from sys.objects where parent_object_id=a.object_id and type=NPK and name in(select Name from sys.indexes where index_id in(select indid from sysindexkeys where and colid=a.column_id)then else end,類型=b.Name,字節數=case when a.max_length=-1 and b.Name!=xml then max/2Gwhen b.Name=xml then 231-1字節/2Gelse rtrim(a.max_length) end,長度=ColumnProperty(a.object_id,a.Name,Precision),小數=isnull(ColumnProperty(a.object_id,a.Name,Scale),0),是否為空=case when a.is_nullable=1 then else end,列说明=isnull(e.value,),默認值=isnull(d.text,) fromsys.columns aleft joinsys.types b on a.user_type_id=b.user_type_idinner joinsys.objects c on a.object_id=c.object_id and c.Type=Uleft joinsyscomments d on a.default_object_id=d.IDleft joinsys.extended_properties e on e.major_id=c.object_id and e.minor_id=a.Col
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年仓储部安全操作规范及应急处理能力考核试卷
- 2025年绿色建筑供暖系统余热回收技术应用考核试卷
- 2025年新时代教师职业素养继续教育考试-教师合作教研能力与团队成果转化考核试卷
- 2025年危险货物运输企业安全生产例会考核试卷
- 2025年新员工安全意识与应急处置能力考核模拟试卷
- 2025年绿色建筑能源系统故障诊断与修复考核试卷
- 2025年新能源汽车高压导线绝缘测试考核试卷
- 太阳能电池片电性能参数测试考核试卷
- 2026年保定理工学院单招职业适应性测试必刷测试卷附答案
- 景德镇市中医院体位转移技术考核
- 利用VR技术辅助小学科学实验教学的新模式探索
- 2024−2025学年广东省深圳市高二上学期期中考试数学检测试题(含解析)
- 医药地区经理未来规划
- 2025年九年级中考数学专题复习-二次函数综合压轴题(与最值有关的问题)(含简单答案)
- 建筑用土工布订购条款
- (完整版)钢结构吊装施工方案
- 八大员-标准员习题库(附答案)
- 城市轨道交通列车司机(技师)职业技能考试题库
- 全国行业职业技能竞赛(电力交易员)考试题库及答案
- 2024年四川省巴中市中考道德与法治试卷真题(含答案解析)
- 四川宜宾普什集团招聘笔试真题2022
评论
0/150
提交评论