Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I specify a recovery model (full, simple or bulk-logged) when creating a database in T-SQL code?

Tags:

tsql

How do I specify a recovery model (full, simple or bulk-logged) when creating a database in a CREATE DATABASE query in T-SQL code?

like image 282
Ivan Avatar asked May 08 '10 18:05

Ivan


1 Answers

Using TSQL, it's part of ALTER DATABASE not CREATE DATABASE.

CREATE DATABASE MyDatabase;
ALTER DATABASE MyDatabase SET RECOVERY SIMPLE;

However, it will inherit the setting from the Model system database, so change that to what you want if it's a common setting.

http://msdn.microsoft.com/en-us/library/ms176061.aspx

http://msdn.microsoft.com/en-us/library/ms190249.aspx

like image 52
Meff Avatar answered Nov 01 '22 02:11

Meff