-- search the txt files contain string "from" and does not contain string "127.0.0.1"
-- database + OS shell + Unix-like utility(grep)
create table #want (fname nvarchar( 512))
create table #discard (tname nvarchar( 512))
insert #want exec master..xp_cmdshell 'cd /d c:/ & grep -l "from" *.txt'
delete from #want where fname is null
--select * from #want
insert #discard exec master..xp_cmdshell 'cd /d c:/ & grep -l "127.0.0.1" *.txt'
delete from #discard where tname is null
--select * from #discard
select * from #want a where not exists ( select 1 from #discard b where a.fname = b.tname)
drop table #discard
drop table #want
-- database + OS shell + Unix-like utility(grep)
create table #want (fname nvarchar( 512))
create table #discard (tname nvarchar( 512))
insert #want exec master..xp_cmdshell 'cd /d c:/ & grep -l "from" *.txt'
delete from #want where fname is null
--select * from #want
insert #discard exec master..xp_cmdshell 'cd /d c:/ & grep -l "127.0.0.1" *.txt'
delete from #discard where tname is null
--select * from #discard
select * from #want a where not exists ( select 1 from #discard b where a.fname = b.tname)
drop table #discard
drop table #want