Home Forums SQL Server 2005 Backups script to set all user database to simple recovery model RE: script to set all user database to simple recovery model

  • if you want to keep it simple and just change recovery model for all user databases run this, copy results to another window and run

    select 'alter database ['+name+'] set recovery simple' from master.sys.databases where database_id > 4 and state_desc = 'online'

    avoid ms_foreachdb, use cursors (there i said it on a thread with Jeff on it). ms_foreachdb creates a cursor in the background anyway, its unsupported, difficult soon as you want to skip some databases, and has been shown to skip databases in error.

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