Friday, 6 March 2020

Query to check recovery model in MSSQL Server Database

Query to check recovery model in database excluding  'master','model','tempdb','msdb'


select [name], DATABASEPROPERTYEX([name],'recovery')
from sysdatabases
where name not in ('master','model','tempdb','msdb')





Recovery model query to simple below:

--Change the recovery mode:
USE master;
GO
-- Set recovery model to SIMPLE


ALTER DATABASE smrmindev  SET RECOVERY SIMPLE;
GO



Recovery model query to full mode below:

 -- Set recovery model to FULL


--Change the recovery mode:
USE master;
GO
 -- Set recovery model to FULL
ALTER DATABASE smrmindev SET RECOVERY FULL;

-- Set recovery model to FULL
ALTER DATABASE smrtest SET RECOVERY FULL;

GO




--- Check the status of recovery model.

select [name], DATABASEPROPERTYEX([name],'recovery')
from sysdatabases
where name not in ('master','model','tempdb','msdb')




No comments:

Post a Comment