Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1183558
  • 博文数量: 181
  • 博客积分: 6155
  • 博客等级: 准将
  • 技术积分: 1805
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-05 09:24
文章分类

全部博文(181)

文章存档

2015年(2)

2014年(3)

2013年(9)

2012年(29)

2011年(30)

2010年(36)

2009年(40)

2008年(32)

分类: 数据库开发技术

2012-08-17 10:33:30

declare   @str   varchar(100)  
  set   @str='999999'     --要搜索的字符串  
   
  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
阅读(8720) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~