Skip to content

Instantly share code, notes, and snippets.

@drmohundro
Created January 4, 2017 02:03
Show Gist options
  • Save drmohundro/c0569f464e99bc16b0219e3e5b7206b7 to your computer and use it in GitHub Desktop.
Save drmohundro/c0569f464e99bc16b0219e3e5b7206b7 to your computer and use it in GitHub Desktop.
T-SQL sp_msforeachdb example
EXEC sp_msforeachdb '
if ''?'' LIKE ''CMS[_]%'' begin
print ''?'';
use [?]
select setting as TransactionGateway, ''?'' as [Database]
from dbo.Setting with(nolock)
where Id = ''TransactionGateway''
END
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment