Skip to main content

SQL Server query to change a database Recovery Model to "SIMPLE".

use master;
go

--
-- Changing Database Recovery Model to "SIMPLE"
--

-- note: replace "DATABASE_NAME" with the target database name
if exists (select top 1 1 from sys.databases where name = 'DATABASE_NAME')
    begin
        if not exists (select top 1 1 from sys.databases where name = 'DATABASE_NAME' and recovery_model_desc = 'SIMPLE')
            begin
                print 'Changing Database Recovery Model to "SIMPLE".';
                alter database [DATABASE_NAME] set recovery simple;
            end;
    end;
go