SQL 查询数据库中包含指定字符串的相关表和相关记录
生活随笔
收集整理的這篇文章主要介紹了
SQL 查询数据库中包含指定字符串的相关表和相关记录
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
declare @str varchar(100)
set @str='我要找的' --要搜索的字符串
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
轉(zhuǎn)載于:https://www.cnblogs.com/freespider/p/10137590.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的SQL 查询数据库中包含指定字符串的相关表和相关记录的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 山东计算机类好的民办大学,2021年山东
- 下一篇: mysql windows身份验证_SQ