如何判断一张数据库表里是否存在一个字段?

[复制链接]
查看11 | 回复3 | 2013-10-29 05:11:16 | 显示全部楼层 |阅读模式
select * from sys.syscolumns where id = (select object_id from sys.objects where name=\\\'table1\\\') and name=\\\'列名\\\'
               
       
       
                 查看原帖
回复

使用道具 举报

千问 | 2013-10-29 05:11:16 | 显示全部楼层
select name as columnNamefrom sys.columnswhere object_id=object_id(\\\'tableC\\\')and name=\\\'TypeName\\\'
               
       
       
                 查看原帖
回复

使用道具 举报

千问 | 2013-10-29 05:11:16 | 显示全部楼层
if exists(select * from sys.columns where object_id(\\\'表名\\\'))/*需要执行的代码*/
               
       
       
                 查看原帖
回复

使用道具 举报

千问 | 2013-10-29 05:11:16 | 显示全部楼层
<img src=\\\"http://wenwen.soso.com/p/20121121/appbig-20121121221706-510336985227992.jpg\\\"></img>
                        致力于网站建设的技术交流,经验分享,资源分享,为网站建设者提供资源交流等站长交流论坛-易采网
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行