SQL Recovery Mode

Hi,

How to make all MSSQL DBs run in Simple log form by default other than FULL so when we srhink DBs the logs will go bybye. :-)

Thanks

[155 byte] By [RubalJain] at [2007-12-22]
# 1
Database settings come from the model database. If you want simple recovery model for all your databases in the future, set this to the model database. If you already have your databases, you have to convert them to Simple recovery model, each one of them. Let me know if you need a sample script to do this for you.
bass_player at 2007-8-30 > top of Msdn Tech,SQL Server,Getting started with SQL Server...
# 2

Yes Please. Sample Script would be gr8 :)

RubalJain at 2007-8-30 > top of Msdn Tech,SQL Server,Getting started with SQL Server...
# 3

SET NOCOUNT OFF
DECLARE @strSQL nvarchar(50)
DECLARE @databaseName nvarchar (255)
DECLARE MyCursor CURSOR FOR --used for cursor allocation
Select name from sysdatabases
Open MyCursor
Fetch Next From MyCursor Into @databaseName
While @@Fetch_Status = 0
BEGIN
SET @strSQL = 'ALTER DATABASE '+ @databaseName + ' SET RECOVERY SIMPLE'
EXEC sp_executesql @strSQL
Fetch Next From MyCursor Into @databaseName
END
Close MyCursor
Deallocate MyCursor

Print 'Recovery Model changed to SIMPLE for all databases'

Hope this helps.

bass_player at 2007-8-30 > top of Msdn Tech,SQL Server,Getting started with SQL Server...
# 4

Thanks a lot. Can I please have script to set the recovery model simple for all new created db as default.

Thanks again.

RubalJain at 2007-8-30 > top of Msdn Tech,SQL Server,Getting started with SQL Server...
# 5
No need for a script. Just change the recovery model of your model database to simple. Every database you create will have the settings you specify for your model database.
bass_player at 2007-8-30 > top of Msdn Tech,SQL Server,Getting started with SQL Server...
# 6

Thanks a lot Bass_Player .. You have been really helpful :)

RubalJain at 2007-8-30 > top of Msdn Tech,SQL Server,Getting started with SQL Server...
# 7
If posts address your questions, please mark an answer. Thank you.
bass_player at 2007-8-30 > top of Msdn Tech,SQL Server,Getting started with SQL Server...
# 8
I did it already
RubalJain at 2007-8-30 > top of Msdn Tech,SQL Server,Getting started with SQL Server...

SQL Server

Site Classified