Solved

EXEC sp_MSForEachDB need to miss table

Posted on 2007-11-14
3
624 Views
Last Modified: 2008-02-07
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
Comment
Question by:James Murrell
  • 2
3 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20278298
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
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 20278299
sorry: NOT IN:

set @doit = ' IF ''?'' NOT IN (''master'', ''tempdb'', ''model'', ''msdb'' ) begin ' + @doit + ' END '
EXEC sp_MSForEachDb @command1=@doit
0
 
LVL 31

Author Comment

by:James Murrell
ID: 20278348
that makes sense - thanks
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now