给定条件:列名
要求:根据列名查找出“列名”所在的表

解决方案 »

  1.   

    select b.name as 表名,a.name as 列名 from syscolumns a,sysobjects b where a.id=b.id and a.name='列名'
      

  2.   

    select * from sysobjects  where id in (select id from syscolumns where name = '列名')
      

  3.   


    select sysobjects.name from sysobjects 
    inner join syscolumns on sysobjects.id=syscolumns.id
    where syscolumns.name='字段名'
      

  4.   

    各位老大,你们那个不对啊。
    在麻烦你们帮帮忙,小弟在此,谢了。select * from wtzc32base..sysobjects a,wtzc32base..syscolumns b
            where b.name = 'fundlocation'
                  and a.id = b.id我觉得表wtzc32base..sysobjects
    和wtzc32base..syscolumns 中的id是两马事,你们觉得呢?
      

  5.   

    select * from sysobjects  where id in (select id from syscolumns where name = '字段名'??这样不行吗?
      

  6.   

    还有   楼主说的
    select * from wtzc32base..sysobjects a,wtzc32base..syscolumns b
            where b.name = 'fundlocation'
                  and a.id = b.id
    这样有什么不对呀?   我觉得要说不对的话那可能是楼主需求提的有问题哦  :)
      

  7.   

    select * from sysobjects  where id in (select id from syscolumns where name = '列名' ) and (xtype='u' or xtype='s') order by name
      

  8.   

    Select Object_Name(ID) as '所属表名' From SysColumns
    Where Name='您的字段名'
      

  9.   

    select object_name(id) as 表名 from syscolumns 
    where name = colname