查表的字段名,主键,字段类型的语句(2)

来源:未知 责任编辑:责任编辑 发表时间:2013-12-01 14:21 点击:
  select name from sysobjects where xtype='u'  
 
2、字段  
SELECT c.name,t.name,c.xprec,c.xscale,c.isnullable     
FROM systypes t,syscolumns c     
WHERE t.xtype=c.xtype     
AND c.id = (SELECT id FROM sysobjects WHERE name='YourTableName')     
ORDER BY c.colid    
3、主键(参考SqlServer系统存储过程sp_pkeys)   
 
select COLUMN_NAME = convert(sysname,c.name)                   
from                                                           
sysindexes i, syscolumns c, sysobjects o                       
where o.id = object_id('[YourTableName]')                      
and o.id = c.id                                                
and o.id = i.id                                                
and (i.status & 0x800) = 0x800                                 
and (c.name = index_col ('[YourTableName]', i.indid,  1) or         
     c.name = index_col ('[YourTableName]', i.indid,  2) or         
     c.name = index_col ('[YourTableName]', i.indid,  3) or         
     c.name = index_col ('[YourTableName]', i.indid,  4) or         
     c.name = index_col ('[YourTableName]', i.indid,  5) or         
     c.name = index_col ('[YourTableName]', i.indid,  6) or         
     c.name = index_col ('[YourTableName]', i.indid,  7) or         
     c.name = index_col ('[YourTableName]', i.indid,  or         
     c.name = index_col ('[YourTableName]', i.indid,  9) or         
     c.name = index_col ('[YourTableName]', i.indid, 10) or         
     c.name = index_col ('[YourTableName]', i.indid, 11) or         
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • Request.ServerVariables 参数大全
  • 执行全文索引时出现权限不足的解决方法
  • 导入excel文件处理流程节点的解决方案
  • 查看sql修改痕迹(SQL Change Tracking on Table)
  • App数据层设计及云存储使用指南
  • PostgreSQL启动过程中的那些事三:加载GUC参数
  • MongoDB安装为Windows服务方法与注意事项
  • Percolator与分布式事务思考(二)
  • 写给MongoDB开发者的50条建议Tip1
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1