Solved

filtering in sp_Msforeachdb

Posted on 2011-09-26
4
584 Views
Last Modified: 2012-05-12

sp_Msforeachdb 'IF ''?'' NOT IN (''tempdb'') alter database ? set recovery simple'
gives error
Option 'RECOVERY' cannot be set in database 'tempdb'.

why is the filtering now happening?
0
Comment
Question by:25112
[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
  • 2
4 Comments
 
LVL 31

Expert Comment

by:James Murrell
ID: 36600813
What version of sql?

0
 
LVL 5

Author Comment

by:25112
ID: 36600816
i am running on 2008
0
 
LVL 31

Accepted Solution

by:
James Murrell earned 500 total points
ID: 36600977
This works for me is sql 2008

EXEC sp_MSforeachdb 'IF ''?'' NOT IN ( ''tempdb'')  
Begin  
Declare @cmd varchar(255)
set @cmd = ''ALTER DATABASE [?] SET RECOVERY SIMPLE''
exec (@cmd)
End'


James
0
 
LVL 5

Author Comment

by:25112
ID: 36601277
good.

practically, what is the difference between yours and mine?
0

Featured Post

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

751 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