Solved

EXEC sp_MSForEachDB need to miss table

Posted on 2007-11-14
3
623 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Backup Job question 4 20
BULK INSERT most recent CSV 19 21
SQL Date Retrival 7 31
Update in Sql 7 12
Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

743 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

12 Experts available now in Live!

Get 1:1 Help Now