• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 644
  • Last Modified:

EXEC sp_MSForEachDB need to miss table

I am using a script to check for information in all db on server...

I need it not do do certain tables - like master, wrtemp any  suggestions

@doit - contain the select statement

EXEC sp_MSForEachDb @command1=@doit
0
James Murrell
Asked:
James Murrell
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you have to check, in the @doit, what the value of ? is...

like this:

set @doit = ' IF ''?'' IN (''master'', ''tempdb'', ''model'', ''msdb'' ) begin ' + @doit + ' END '
EXEC sp_MSForEachDb @command1=@doit
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
sorry: NOT IN:

set @doit = ' IF ''?'' NOT IN (''master'', ''tempdb'', ''model'', ''msdb'' ) begin ' + @doit + ' END '
EXEC sp_MSForEachDb @command1=@doit
0
 
James MurrellProduct SpecialistAuthor Commented:
that makes sense - thanks
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now