Skip to content
Menu
莱风 莱风
  • 序章
莱风 莱风

按关键字搜索所有表和字段

Posted on 2021/05/242024/02/13 by zhou
declare @str varchar(100)
set @str='keyword'  --要搜索的字符串

declare @s varchar(8000)
declare tb cursor local for
    select '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

发表回复 取消回复

您的邮箱地址不会被公开。 必填项已用 * 标注

5 + 5 = ?

近期文章

  • Nginx设置开机自启及异常停止后自动重启
  • redhat Linux centos7 安装或卸载官方MySQL8
  • WordPress文章游客评论时添加验证码
  • 宝塔面板MySQL设置单数据库主从双向同步
  • wordpress修改底部版权信息删除RSS订阅按钮

分类

  • docker (4)
  • Linux (2)
  • MySQL (1)
  • sql (8)
  • Windows (5)
  • WordPress (5)
  • 未分类 (12)
  • 飞跃长城 (5)

近期评论

    其他操作

    • 登录
    ©2025 莱风