Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 600
  • Last Modified:

filtering in sp_Msforeachdb


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
25112
Asked:
25112
  • 2
  • 2
1 Solution
 
James MurrellProduct SpecialistCommented:
What version of sql?

0
 
25112Author Commented:
i am running on 2008
0
 
James MurrellProduct SpecialistCommented:
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
 
25112Author Commented:
good.

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now