Using Model to Change Default Database Settings

During a Twitter conversation today Malik Alamin (Twitter) asked about the Autogrow settings on his databases. The conversation naturally progressed to the question of how you change the default behavior and set all newly created databases to have user defined settings. Brent Ozar (Blog | Twitter) was able to point us in the right direction to find a solution. Modifying the model database.

About the model Database

When a new database is created either by using the CREATE DATABASE statement, that mean via SSMS as well, the model database is used as a template. This means that change made to the model database settings, including tables, permissions, stored procedures, and functions will all transfer over to the newly created database.

According to the TechNet article about the model database some file sizes may look different depending on what version of SQL Server is installed. Also, there are some things that cannot be modified in the model database. Items like CHANGE_TRACKING, ENCRYPTION, and TRUSTWORTY cannot be modified. A full list of restrictions can be found in the TechNet Article.

Example

I need to set the auto grow on my data file to Autogrow by 10% instead of 1 MB as was the default on my instance. I can run the ALTER DATABASE command or use SSMS against the model database

USE [master] GO ALTER DATABASE [model] MODIFY FILE ( NAME = N'modeldev', FILEGROWTH = 10%) GO USE [master] GO ALTER DATABASE [model] MODIFY FILE ( NAME = N'modeldev', FILEGROWTH = 10%) GO

Media_httpwwwjonathan_rrrgd
Making these changes will alter all newly created databases to have the same settings.

Note: Jorge Segarra (Blog | Twitter) pointed out that this does NOT work in a SharePoint environment. SharePoint does not use the model database when it creates new site databases.

Book Review: Microsoft SQL Server 2008 - Implementation and Maintenance - Self Pace Training Kit

Media_httpwwwjonathan_dblcj
A few months ago I reviewed my training plan for 2009 and realized I needed to update my certifications and take the SQL Server 2008 - Implementation and Maintenance Exam 70-432. While I felt I had enough experience and knowledge to take the exam I wanted to ensure I would be comfortable with all of the areas covered by the exam. I turned to my training plan on Microsoft's Learning site and purchased the recommended book by Mike Hotek (Twitter)

Price

The recommended price on the cover is $69.99. At the time of publishing this article the book could be found for around $45.00 at many bookstores including amazon.com. The book comes with a 180 day trial copy of SQL Server 2008 Enterprise, ebook, practice test, and example scripts and databases.

The Good

The book was set up in a very logical progression of technical building blocks. It started out with the very basics of proper setup and configuration. The author then progressed through some database basics and how they related specifically to SQL Server 2008. More advanced topics such as Policy Based Management, Automation, Monitoring and Performance Tuning were then covered. Finally ending with a very in depth look at High Availability solutions offered by SQL Server 2008.

The Bad

Some topics, partitioning in particular, covered basic information but could have been emphasized better as they had a very large presence on the test. That being said, Mike does cover partitioning in an entire chapter of the book but it seemed that this material was more prominent on the test that 1 chapter worth of material.

Overall

I would rate the book at 4.5 out of 5 stars. What made this book really shine was the inclusion of the practice test. After completion of a practice test, users are presented with a reading list based on the areas of the test where the user needs to straighten their skills. This reading list includes material not only in the book but aggregates information from across the web.

I strongly recommend that people interested in taking Exam 70-432 purchase this book.

MS Access ODBC Connetion Timeout Error

There are some of us unfortunate DBAs out there that are forced to support MS Access connections to our database. I am one of those poor souls.

The Problem

I manage a Microsoft Dynamics NAV database with over 26,000 tables. When one of our users was trying to create a linked table in Access 2007 he was presented with a ODBC--call failed Timeout expired (#0) error.
Media_httpwwwjonathan_tizfd
Aside: I am always so appreciative of MS descriptive error messages. I was unable to reproduce this error on my system. The main difference is that I am a member of the sysadmin fixed server role and he is not. I didn't expect this to be my issue but ran a quick test. Low and behold when I set his user as a member of sysadmin he was able to list all of the table. Having anyone other than a DBA as a member of the sysadmin fixed server role is unacceptable so I engaged Microsoft for some assistance.

The Environment

Physical Server HP DL380 Windows Server 2008 Enterprise SQL Server 2008 SP1 Enterprise 12 GB of RAM Lefthand Networks iSCSI SAN

The Solution

Disable the ODBC Timeout value

On the client computer, click Start -> Run -> type "regedit" (without double quotes) and press Enter, locate the registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Access Connectivity Engine\Engines\ODBC

In Access

Click to highlight QueryTimeout, and then on the Edit menu, click Modify. Change the value to 0 (zero). Close and re-open Access

SQL Server Trace Flags

Media_httpwwwjonathan_dsdco
During a recent project to deploy Microsoft Dynamics NAV I ran into an error that required me to set the trace flag 4616. In a my previous post, Microsoft Dynamics NAV Trace Flag 4616, I covered the error and how to set the flag. This post will dive deeper into trace flags. Trace flags are used to turn on or off particular behavior on a SQL Server especially to diagnosed performance and debug stored procedures. A list of Trace flag's can be found on Microsoft's Books Online. There are some trace flags that are undocumented. Use these with extreme caution. The trace flag that I enabled for Microsoft Dynamics NAV is described in the table below.
4616 Makes server-level metadata visible to application roles. In SQL Server, an application role cannot access metadata outside its own database because application roles are not associated with a server-level principal. This is a change of behavior from earlier versions of SQL Server. Setting this global flag disables the new restrictions, and allows for application roles to access server-level metadata. Scope: global only
Trace flags can be set globally or per session. Global trace flags can be set at startup with the -T switch or can be set with the DBCC TRACEON and DBCC TRACEOFF command. DBCC TRACESTATUS is used to determine what flags are currently enabled. Each flag has its own risks. Make sure you research what each flag does and the security risk of enabling each before you implement them.

Microsoft Dynamics NAV Trace Flag 4616

Connecting to a Navision Database on a new server will generate an error about the trace flag 4616 not being set. Below are the instructions on how to correct this error.

Media_httpwwwjonathan_haooc

The trace flag is a global flag that is set on the entire SQL server instance through the advanced properties tab in the SQL Server Configuration Manager.

1. Open the SQL Server Configuration Manager

Media_httpwwwjonathan_bhexy
2. Right click no the SQL Server (MSSQLSERVER) instance and click Properties

3. Select the Advanced tab and go to the Statup Parameters field.

Media_httpwwwjonathan_bxfrk
4. Add <;-t4616> without the <> to the end of the startup parameters.

5. Restart the SQL Services for the flag to take effect.

All solutions are provided as-is.