根据列名找表

sp_maoqi 2006-07-19 05:32:43
给定条件:列名
要求:根据列名查找出“列名”所在的表
...全文
239 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
十一月猪 2006-07-21
  • 打赏
  • 举报
回复
select object_name(id) as 表名 from syscolumns
where name = colname
kisa99 2006-07-20
  • 打赏
  • 举报
回复
select * from sysobjects where id in (select id from syscolumns where name = '列名' ) and (xtype='u' or xtype='s') order by name
gahade 2006-07-20
  • 打赏
  • 举报
回复
没关系

结贴就好了!:)
liangpei2008 2006-07-20
  • 打赏
  • 举报
回复
本贴右上方管理-给分!
sp_maoqi 2006-07-20
  • 打赏
  • 举报
回复
结贴
怎么样结的啊?
我好给分啊
liangpei2008 2006-07-20
  • 打赏
  • 举报
回复
Select Object_Name(ID) as '所属表名' From SysColumns
Where Name='您的字段名'
sp_maoqi 2006-07-20
  • 打赏
  • 举报
回复
真不好意思,是我搞错了。
xyxfly 2006-07-19
  • 打赏
  • 举报
回复
还有 楼主说的


select * from wtzc32base..sysobjects a,wtzc32base..syscolumns b
where b.name = 'fundlocation'
and a.id = b.id
这样有什么不对呀? 我觉得要说不对的话那可能是楼主需求提的有问题哦 :)
xyxfly 2006-07-19
  • 打赏
  • 举报
回复
select * from sysobjects where id in (select id from syscolumns where name = '字段名'

??这样不行吗?
sp_maoqi 2006-07-19
  • 打赏
  • 举报
回复
各位老大,你们那个不对啊。
在麻烦你们帮帮忙,小弟在此,谢了。

select * from wtzc32base..sysobjects a,wtzc32base..syscolumns b
where b.name = 'fundlocation'
and a.id = b.id

我觉得表wtzc32base..sysobjects
和wtzc32base..syscolumns 中的id是两马事,你们觉得呢?
marco08 2006-07-19
  • 打赏
  • 举报
回复

select sysobjects.name from sysobjects
inner join syscolumns on sysobjects.id=syscolumns.id
where syscolumns.name='字段名'
gahade 2006-07-19
  • 打赏
  • 举报
回复
select * from sysobjects where id in (select id from syscolumns where name = '列名')
云中客 2006-07-19
  • 打赏
  • 举报
回复
select b.name as 表名,a.name as 列名 from syscolumns a,sysobjects b where a.id=b.id and a.name='列名'

34,837

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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