首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

在数据库中找到数据所在的表的步骤

2012-12-18 
在数据库中找到数据所在的表的方法sql2005中,想很快找到某个数据所在的表.比如数据: ABC ,这个数据在哪

在数据库中找到数据所在的表的方法
sql2005中,想很快找到某个数据所在的表.
比如数据:" ABC" ,这个数据在哪个表中一种方法是依次打开每个表,然后找到"ABC“
不用这种方法,该怎么实现?
[最优解释]
http://netlive.blog.163.com/blog/static/186581237201141642157742/
[其他解释]
这个有点不好整  好像有一个脚本可以实现  现在找不到了
[其他解释]

引用:
http://netlive.blog.163.com/blog/static/186581237201141642157742/


declare @str varchar(100)
set @str='这里请自己填写'  --要搜索的字符串

declare @s varchar(8000)
declare tb cursor local for
select s='if exists(select 1 from ['+b.name+'] where ['+a.name+'] like

''%'+@str+'%'')
 print ''所在的表及字段: ['+b.name+'].['+a.name+']'''
from syscolumns a join sysobjects b on a.id=b.id
where b.xtype='U' and a.status>=0
 and a.xusertype in(175,239,231,167)
open tb
fetch next from tb into @s
while @@fetch_status=0
begin
 exec(@s)
 fetch next from tb into @s
end
close tb
deallocate tb


帮粘贴下代码
[其他解释]
引用:
http://netlive.blog.163.com/blog/static/186581237201141642157742/


感谢!!!!!

热点排行