Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

filtering in sp_Msforeachdb

Posted on 2011-09-26
4
Medium Priority
?
595 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 2000 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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.

721 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