百分求 sql 牛人-----请进
一个数据库data_01,里面有很多很多表table_01````,差不多100多张;每张表里有20多个字段;问题是这样的:      现在我知道字段名称;如何根据字段名查询出我字段所在的表名???????????
------解决方案--------------------declare @colname sysname 
 set @colname =  '列名 '   
 select DISTINCT a.name from  sysobjects as a  
 inner join syscolumns as b on a.id = b.id 
 where a.xtype =  'U ' and a.status >  0 and b.name = @colname 
------解决方案------------------------创建测试数据 
 if object_id( 'tbTest1 ') is not null 
 drop table tbTest1 
 if object_id( 'tbTest2 ') is not null 
 drop table tbTest2 
 if object_id( 'tbTest3 ') is not null 
 drop table tbTest3 
 GO 
 create table tbTest1(姓名 varchar(10),年龄 int) 
 create table tbTest2(姓名 varchar(10),出生日期 datetime) 
 create table tbTest3(产品名称 varchar(10),数量 int) 
 GO 
 ----查询 
 declare @colname sysname 
 set @colname =  '姓名 '   
 select DISTINCT a.name from  sysobjects as a  
 inner join syscolumns as b on a.id = b.id 
 where a.xtype =  'U ' and a.status >  0 and b.name = @colname   
 ----清除测试环境 
 drop table tbTest1,tbTest2,tbTest3   
 /*结果 
 name 
 --------------- 
 tbTest1 
 tbTest2 
 */ 
------解决方案--------------------select t.*,v.name from syscolumns t,sysobjects v 
 where t.id=v.id 
 and t.name= 'did ' 
 如果多个表存在该字段,则会显示多个
------解决方案--------------------测试数据 
  都写上了~没分混了~~
------解决方案--------------------呵呵 
 也不说什么思路 
 就是你要熟悉以下这几个常用的系统表 
 sysobjects     --所有的表名 
 syscolumns   --所有的表里的列名  
 systypes    --所有的类型 
 ----lz:可以自行打开这几个表看看它们有什么关系、关联等等
------解决方案--------------------当你明白系统表放的就是你表结构的东西,你就知道如果做了