Solved

EXEC sp_MSForEachDB need to miss table

Posted on 2007-11-14
3
631 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 143

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 143

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

696 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