SQL实现全库搜索关键字所在表位置

if OBJECT_ID('tempdb..#t') is not null drop table tempdb..#t ; declare @s nvarchar(256) set @s='123' declare @sql nvarchar(max) select top 100 @sql=ISNULL(@sql+';','')+'insert #t select top 1 '''+tablename+''',''' +columnname+''','+columnname+' from '+tablename+' where charindex('''+@s+''','+columnname+')>0' from ( select a.name as tablename,b.name as columnname from sysobjects a join syscolumns b on a.id=b.id join systypes c on b.xtype=c.xtype where a.type='u' and c.name in('text','ntext','varchar','char','nvarchar','nchar') ) t create table #t(tablename nvarchar(128),columnname nvarchar(128),columndata nvarchar(max)); exec(@sql) select tablename as 表名称,columnname as 列名称,columndata as 数据列 from #t GO

SQL执行历史记录:

if OBJECT_ID('tempdb..#t') is not null drop table tempdb..#t ; declare @s nvarchar(256) set @s='123' declare @sql nvarchar(max) select top 100 @sql=ISNULL(@sql+';','')+'insert #t select top 1 '''+tablename+''',''' +columnname+''','+columnname+' from '+tablename+' where charindex('''+@s+''','+columnname+')>0' from ( select a.name as tablename,b.name as columnname from sysobjects a join syscolumns b on a.id=b.id join systypes c on b.xtype=c.xtype where a.type='u' and c.name in('text','ntext','varchar','char','nvarchar','nchar') ) t create table #t(tablename nvarchar(128),columnname nvarchar(128),columndata nvarchar(max)); exec(@sql) select tablename as 表名称,columnname as 列名称,columndata as 数据列 from #t GO

SQL操作返回历史记录:

2023-02-26 21:10:51:558 输入:if OBJECT_ID('tempdb..#t') is not null drop table tempdb..#t ; declare @s nvarchar(256) set @s='123' declare @sql nvarchar(max) select top 100 @sql=ISNULL(@sql+';','')+'insert #t select top 1 '''+tablename+''',''' +columnname+''','+columnname+' from '+tablename+' where charindex('''+@s+''','+columnname+')>0' from ( select a.name as tablename,b.name as columnname from sysobjects a join syscolumns b on a.id=b.id join systypes c on b.xtype=c.xtype where a.type='u' and c.name in('text','ntext','varchar','char','nvarchar','nchar') ) t create table #t(tablename nvarchar(128),columnname nvarchar(128),columndata nvarchar(max)); exec(@sql) select tablename as 表名称,columnname as 列名称,columndata as 数据列 from #t GO

2023-02-26 21:10:51:558 输出:全库关键字搜索 : 19行

smartsofthelp 最好的数据库开发软件

下载地址:https://pan.baidu.com/s/1RzJq5rKEJWq5xGUIo7jYjw?pwd=8888

下载https://pan.baidu.com/s/1RzJq5rKEJWq5xGUIo7jYjw?pwd=8888

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值