Solved

filtering in sp_Msforeachdb

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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

760 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

22 Experts available now in Live!

Get 1:1 Help Now