/*============================================================================
  File:     3_Database_Settings.sql

  Summary:  This script reviews how to view existing database
			configuration settings and alter them.

  Date:     October 2014

  SQL Server Version: 2005/2008/2008R2/2012/2014
------------------------------------------------------------------------------
  Written by Erin Stellato, SQLskills.com

  For more scripts and other useful content, go to:
	http://www.SQLskills.com

  This script is intended only as a supplement to demos and lectures
  given by Erin Stellato.  
  
  THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF 
  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 
  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  PARTICULAR PURPOSE.
============================================================================*/


/*
	check current settings 
*/
SELECT 
	[database_id],
	[name],
	[collation_name],
	[recovery_model_desc],
	[compatibility_level],
	[is_auto_shrink_on],
	[is_auto_create_stats_on],
	[is_auto_update_stats_on],
	[is_auto_update_stats_async_on],
	[is_parameterization_forced],
	[page_verify_option_desc]	
FROM [master].[sys].[databases]
ORDER BY [database_id];

/*
	change settings
*/
ALTER DATABASE [AdventureWorks2014] COLLATE SQL_Latin1_General_CP1_CI_AS;
ALTER DATABASE [AdventureWorks2014] SET RECOVERY FULL;
ALTER DATABASE [AdventureWorks2014] SET COMPATIBILITY_LEVEL = 110;
ALTER DATABASE [AdventureWorks2014] SET AUTO_SHRINK OFF;
ALTER DATABASE [AdventureWorks2014] SET AUTO_CREATE_STATISTICS ON;
ALTER DATABASE [AdventureWorks2014] SET AUTO_UPDATE_STATISTICS ON;
ALTER DATABASE [AdventureWorks2014] SET AUTO_UPDATE_STATISTICS_ASYNC OFF;
ALTER DATABASE [AdventureWorks2014] SET PARAMETERIZATION SIMPLE;
ALTER DATABASE [AdventureWorks2014] SET PAGE_VERIFY CHECKSUM;

ALTER DATABASE [AdventureWorks2014] 
	SET AUTO_SHRINK OFF, 
		AUTO_CREATE_STATISTICS ON, 
		AUTO_UPDATE_STATISTICS ON;