Tuesday, December 20, 2011

Change DB options (SQL)

If you want to change DB options on several databases, you could either click yourself to death, or simply use the following T-SQL to modify all user databasases at once:

----------------------

EXECUTE sp_MSforeachdb

'

IF (''?'' NOT IN (''master'', ''tempdb'', ''msdb'', ''model''))

   EXECUTE (''ALTER DATABASE [?] SET RECOVERY SIMPLE  WITH NO_WAIT'') '

---------------------
In this example, I`ve used "SET RECOVERY SIMPLE WITH NO_WAIT", but you can use any other.

No comments: