Solved

filtering in sp_Msforeachdb

Posted on 2011-09-26
4
572 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
  • 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

867 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