This commit is contained in:
2023-05-09 18:21:47 +00:00
parent dc9eca0953
commit 3dd59e20d8
118 changed files with 12010 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
declare @dbNames nvarchar(max)
set @dbnames = 'VEPROMS_%'
declare @CommandLine nvarchar(max)
set quoted_identifier off -- Allows single quotes to be used in the query'
set @CommandLine = "
select Count(*) HowMany from ~rofsts where rolookup like '%@HSP(%'
"
set quoted_identifier on
declare @CommandLines nvarchar(max)
select @CommandLines = Coalesce(@CommandLines + ' UNION' + char(10), '') + 'select ''' + Name + ''' DBName, * from ( ' + Replace(Replace(@CommandLine,'~','{Name}.dbo.'),'{Name}',Name) + ') T1'
from Sys.Databases where name like @dbNames and name not like '%test'
Set @CommandLines = 'Select * from ( ' +@CommandLines + ') t2 '--where HowMany > 0'
print @CommandLines
EXEC SP_EXECUTESQL @CommandLines