SQL语句问题,各位大虾别嫌分少,我经常登陆也不知道为什么不给加分,只有这些了

Aimis 2006-06-13 11:02:14
SQL语句问题,各位大虾别嫌分少,我经常登陆也不知道为什么不给加分,只有这些了~


请问:

我怎么查到一个sql表中是否包含某一列。


Table1:
ID
Name
Desc

Table2:
ID
Name

我如何从sql与语句中判断Table2是否包含[Desc]这个字段
...全文
140 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
baggio328 2006-08-15
  • 打赏
  • 举报
回复
想有分跟经常登陆没有关系
要解答问题才行
Aimis 2006-06-14
  • 打赏
  • 举报
回复
感谢大家,jt
业余程序员 2006-06-13
  • 打赏
  • 举报
回复
要想做一个真正的程序员,不要碰到一点问题就去到处发贴问.你可以在社区里面搜索一下相关的精确词.肯定有你要找的结果.要学会如何去找答案,去找结果.这样才能很快的提高你的水平.
diandian82 2006-06-13
  • 打赏
  • 举报
回复
用什么schema相关的方法可以读取列的信息,你查一下
pshy 2006-06-13
  • 打赏
  • 举报
回复
從sql的系統表syscolumns中查詢(name字段)
wumingbing_8027 2006-06-13
  • 打赏
  • 举报
回复
用DESC取出比较可以不?
Aimis 2006-06-13
  • 打赏
  • 举报
回复
up
沙发
伴老思源 2006-06-13
  • 打赏
  • 举报
回复
if exists( select * from syscolumns
where [name]='列名'
and [id]=( select [id] from sysobjects where [name] = '表名' ) )

//存在
else
//不存在
playwarcraft 2006-06-13
  • 打赏
  • 举报
回复
測試test_table中是否有c1這欄位

select count(*) from syscolumns
where [name] ='c1'
and [id] =(select [id] from sysobjects where [name]='test_table')
playwarcraft 2006-06-13
  • 打赏
  • 举报
回复
測試:
create table test_table (c1 int, c2 int,c3 int)
select [name] from syscolumns
where [id] =(select [id] from sysobjects where [name]='test_table')
drop table test_table
-------------------
result:
name
-------
c1
c2
c3
(3 row(s) affected)
playwarcraft 2006-06-13
  • 打赏
  • 举报
回复
select [name] from syscolumns
where [id] =(select [id] from sysobjects where [name]='table_name')
fffgtao 2006-06-13
  • 打赏
  • 举报
回复
select * from Table1
然后再查每一列的名字,不正规的解法,不过应该好用.
Aimis 2006-06-13
  • 打赏
  • 举报
回复
楼上fq的不厚道


真会装**

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧