I’ve covered what needs to happen before you install SQL Server – now, let’s talk about what to do immediately after the setup finishes.
Install not just the service packs, but also the cumulative updates.
Starting with SQL Server 2005′s Service Pack 2, Microsoft releases hotfixes in cumulative packs. These updates do more than just fix bugs: they improve how SQL Server performs. These updates are free performance benefits – and who doesn’t like that?
To find the latest service packs and cumulative updates, check out the SQL Server Release Date Calendar at SQLServerPedia. It’s got version numbers, build numbers, and download links for all versions of SQL Server in one place.
Double-check that Instant File Initialization is enabled.
Paul Randal wrote an excellent blog post on how to tell if instant initialization is enabled. Follow the instructions in his post, and you’ll know for sure. (While you’re there, subscribe to his blog – it’s chock full of SQL-y goodness.)
Best Practice: Move TempDB to its own drive.
By default, the TempDB files are put on the same drive as the SQL Server binaries. Even if the user chooses a custom install, TempDB still goes on the same drive as the other data files, and that’s not a good idea either. Instead, the TempDB data files should be on their own dedicated drive.
Fix this by first moving TempDB to its own drive. In this example, I put the data file on the T drive and the log file on the L drive. (Be aware that the directory paths must already exist.)
use master
go
alter database tempdb modify file (name=’tempdev’, filename=’T:\MSSQL\DATA\tempDB.MDF’, size = 1mb)
go
alter database tempdb modify file (name=’templog’, filename=’L:\MSSQL\LOGS\templog.LDF’, size = 1mb)
go
I only set a 1mb file size because SQL Server does something tricky: even though we’re telling it to use a different drive letter, it will look for this amount of free space on the drive TempDB currently uses! If SQL Server was installed on the server’s C drive, for example, and we try to create a 10gb TempDB file on a T: drive, that SQL command will fail if there isn’t 10gb of free space on the C drive. Yep, it’s a bug – get over it.
After this code runs, restart the SQL Server. That will create the new TempDB file on the new drive. Manually delete the old TempDB file on the original drive, because SQL Server doesn’t delete that itself.
Now that TempDB is on the right drive, expand it to the full size you want, and then create additional TempDB files. The current guidance from Paul Randal is to make 1/4-1/2 the number of TempDB files that you have processor cores. If you’ve got a quad-socket, quad-core box, that’s 16 cores, so you need 4 to 8 TempDB files. Generally I start on the lower end unless I know the server will be under heavy TempDB pressure from its applications.
Here’s the code to create one additional TempDB data file – you can modify this for more files:
USE [master]
GO
ALTER DATABASE [tempdb] ADD FILE ( NAME = N’tempdev2′, FILENAME = N’T:\MSSQL\DATA\tempdev2.ndf’ , SIZE = 10GB , FILEGROWTH = 0)
GO
The data file creation should only take a couple of seconds – if it takes more than ten seconds, then instant file initialization isn’t configured correctly. We talked about this back in the pre-installation checklist, so go back and revisit that before you create the next TempDB file. Fix the security to allow for instant file initialization now – it has a huge performance impact on database growth.
Assuming that one file growth only took a couple of seconds, then go ahead and create the rest of the TempDB data files.
Notice that I don’t have filegrowth enabled. You want to proactively create the TempDB files at their full sizes to avoid drive fragmentation. If you have a dual-cpu quad-core server (8 cores total) and an 80-gb array for TempDB data, you would create eight 10gb files for TempDB. That way, each file is contiguous, all laid out in one big chunk. If you create them as smaller files and let them autogrow, then the disk will be fragmented all over the place because the files will be growing at random times. Plus, you could end up with differently sized TempDB files if one of them happened to grow faster than the rest. That’s why I pre-grow all of the TempDB files ahead of time and get them at exactly the right size.
Configure SQL Server memory for best practices.
Sounds easy, right? Go into SQL Server Management Studio, right-click on the server name and click Properties, go into Memory, and just configure it. There’s only a couple of fields – how hard could it be?

Oh, this screen is full of danger and pitfalls.
First, that tricky checkbox that says “Enable AWE”. Check that box if you’re using a 32-bit server with more than 4 gigs of memory.
Second, the minimum and maximum memory amounts are important, especially since we gave the SQL Server account the permission to lock its pages in memory. If other applications are running on this server, we need to specify how much memory we want SQL Server to take.
Ideally, no one would ever remote desktop into a SQL Server and run programs. Unfortunately, this happens, and we have to plan for it by leaving enough free memory for people to run things like SQL Server Management Studio. When I’m first building a server that isn’t running any other applications at all, I like to leave 10% of the memory free, or 2gb, whichever is larger. Then I monitor the free memory over the course of a month or two, and adjust it up or down during the next outage window.
If the server does multiple duties like act as a web server or application server, we have to be much more conservative with memory. Application owners never seem to know how much memory they’ll really use in production: SAP BW’s Netweaver, for example, tends to use anywhere from 10% to 50% of the memory on our production server, and it’s tough to predict. As a result, we have to leave the SQL Server’s memory allocation at just 50% of the available memory on the server.
I set the minimum server memory to 50% of the server’s total memory. This will let SQL Server release memory if the server comes under memory pressure, like if someone remote desktops in and runs a very poorly written application.
The only way to know the right answer long term is to use Perfmon or a performance monitoring utility to watch the server’s free memory. I’ve written up a separate blog post on using Perfmon for SQL Server monitoring.
Set the Default Database Path
Even if you chose this during setup, we need to revisit it because SQL Server puts both the data files and the log files in the same directory. In SSMS, right-click on the server name and click Database Settings. The paths for the data files and log files can be configured from there.
Of course, this assumes that we have separate drives for the data and log files, which is the right way to go for performance purposes.
Tweak the model database.
This tip comes courtesy of reader John Langston. Whenever a new database is created, SQL Server uses the “model” database as – well, as the model. You can make changes to that database, and those changes will automatically happen to any new databases. John writes:
I also like to go to model and change the recovery model from FULL since we use SIMPLE a lot, even in production and also change the datafile autogrowth setting from 1 MB.
Great tip!
Configure Database Mail with public & private profiles.
Database Mail is a pure SMTP solution that beats the daylights out of SQL 2000′s SQLmail. It doesn’t require Outlook to be installed on the database server, doesn’t need any MAPI code, and works with any company email server that can be accessed via SMTP.
There’s plenty of sites on the web that explain how to configure Database Mail, but I want to address something: be aware that developers can use Database Mail for things that SQL Server shouldn’t be doing. For example, they may decide to use Database Mail to send out mass emails to your end users or customers. There’s nothing technically wrong with that, but it increases the load on the database server and it sends all outgoing email with the SQL Server’s Database Mail account.
At our shops, we use internal emails like (servername)@ourcompany.com to identify which server is sending the database mail. Those email addresses make sense to us because we just need to know where the alerts are coming from – we would never hit Reply to a server-generated email.
However, if developers use SQL Server to send out emails directly to customers, those customers will indeed reply. I had a nasty problem where a couple of developers decided to purge old customer accounts, and they used SQL Server’s Database Mail to broadcast an announcement to those users. The email read something like, “You haven’t used your account in 30 days, so we’re deleting it. Please contact us for questions.” Of course a lot of customers got aggravated and sent some nastygram replies, which arrived in the IT team’s inboxes, who had no idea what was going on. After some confusion, we were able to track down the guilty party, but those emails never should have gone out from the IT staff.
Bottom line: if you decide to use Database Mail (and you should), consider setting up separate private and public email profiles. The public email profile used by the developers should be sent from the developer management team’s group email address – that way, they can address any replies themselves.
Configure SQL Server Agent’s failsafe operator.
After configuring Database Mail, create at least one SQL Server Agent operator. This operator’s email address should be a distribution list for the database administrator group. Even if the company only has one DBA, never use an individual person’s email address – use a distribution list instead. When the DBA goes on vacation or gets a job at another company (or heaven forbid, gets fired), it’s easier to add someone to a single distribution list instead of modifying operators on dozens or hundreds of servers.
Then right-click on the SQL Server Agent, configure the alerting system to use Database Mail, and set up that DBA group as the failsafe operator. That way if anything happens and SQL Server doesn’t know who to alert, it can alert the group.
Create default alerts for severities 16 through 25.
SQL Server’s alerting system has the ability to notify operators whenever major things break inside the database. These include running out of space in log files, backup failures, failed logins and other things DBAs just need to be aware of. Don’t rely on this as your only SQL Server monitoring system, because it only sends alerts when it’s too late to take proactive action, but still, it’s better than nothing.
The below script will set up an alert for severity 16. Copy this and repeat the same thing for 17-25, but change ‘Database Team’ to be the name of your default operator. Notice that @delay_between_responses is set to 60 – that means if it sends out an alert, it won’t repeat that same alert for 60 seconds. This is useful because when a database runs out of drive space, for example, all hell will break loose for a minute or two, and you don’t want hundreds of emails and pages per minute.
USE [msdb]
GO
EXEC msdb.dbo.sp_add_alert @name=N’Severity 016′,
@message_id=0,
@severity=16,
@enabled=1,
@delay_between_responses=60,
@include_event_description_in=1,
@job_id=N’00000000-0000-0000-0000-000000000000′
GO
EXEC msdb.dbo.sp_add_notification @alert_name=N’Severity 016′, @operator_name=N’Database Team’, @notification_method = 7
GO
Install the SQL Server 2005 Performance Dashboard Reports.
These are an insanely cool and free extension for SQL Server Management Studio.
- Download the SQL Server 2005 Performance Dashboard Reports
- Read about them on SQL-Server-Performance
You run the setup.exe on your personal workstation, and then you have to execute the setup.sql script on each server that you want to monitor. It only takes a few minutes, but the information that it gathers will help you manage your server better throughout its lifetime.
Set Up Maintenance Plans
This is where things start to get different on a shop-by-shop basis. Some places use native backups, some places use backup compression software, some places use index defrag software, and so on. I’ve written a lot of articles about my personal backup best practices, and one about why SQL native backups suck. (Hey, if I was politically correct, I’d be writing manuals instead of reviews.)
Benchmark It, and Find the Slowest Link
Before it goes into production, load test and stress test it to find where you’ll need to improve performance down the road. Before it goes live, this is your one chance to really bang the daylights out of it without anybody complaining.
To help, I recommend the book Professional SQL Server 2005 Performance Tuning from WROX. It does a great job of covering all the different performance areas – storage, memory, CPU, network – and showing you how to detect bottlenecks and remove them.
Want Performance Tips? Check Out My Articles.
I’m sure my readers have plenty of opinions about what should be done right away after setup. If you’ve got one, feel free to leave a comment here or contact me.
Hi, I’m a developer but I’ve been getting into SQL tuning more and more on some projects … Read the internal troubleshooting 2008 book very helpful and well written !
I’m working on a small 64 bit server and only have two drives to dedicate to SQL
… Where should I put the tempdp ? All with the mdf, all with the ldf, or should I split it ?
David – thanks, glad you liked the book. If you only have two drives, I’m assuming you mean two RAID arrays. It all depends on the amount of user database reads, writes, and TempDB load. You need to strike a balance for your needs. I’ve seen shops that put user databases and log files on one array, and TempDB on its own array because they incur so much TempDB load.
If you literally only have two drives, not two RAID arrays, then make a mirror out of them (RAID 1) and protect your data from failing hard drives.
Hope that helps!
Literally two, lol …
[...] – Securing Your Database Server Brent Ozar – SQL Server 2005 Checklist Part 1 and Part 2 SQL Server Best Practices – Disk Partition Alignment Best Practices for SQL [...]
Does anyone know how to add extra accounts to the SQL Administrators group on a cluster install?? I added the 3 (current) DBA domain accounts during the install on the DB Engine Configuration screen but now need to add a new starters account. Where can I do this??
Doesn’t matter. Managed to connect to Management Studio (didn’t know I had to look for DB Engine on the cluster name, not the server name) and added it in there.
[...] Ozar explained it here better. July 1, 2010 5:01 am Philip Kelley That’s worth knowing about. Not the issue [...]
Hello Brent,
I just want to say my heartily thanks to you, for your valuable contribution for SQL Server. The best part is that you are sharing your hard earned knowledge with everyone and everyone is get benefited by this. Simply I will pray to GOD to give you long life and send people like you on this earth. I pray to GOD to make your all good desired come true.
Just keep it up and we also like to share our knowledge with you, if it make some value to you.
Million Thanks again,
Nikesh
Nikesh – wow, thanks, sir!
Brent,
I am the IT Manager for a GC (Commercial Construction). This 2 part set may have saved me plenty of heartache.
I know you don’t do the crystal ball thing but I need to try and get some clarification if possible.
This is “Tabula Rosa” for us. No database history, never had a SQL installation, NOTHING to go on.
We are putting in SQL2008R2 Standard Ed. with NOS=MS Server 2008R2; Server has 24GBRAM, 2xQuadCore Processors; NOS & SQL Programs on 250GB Mirrored set C:; Raid5(4TB set)E:(200GB)for TEMPDB, F:(400GB)Contract Manager,(Accounting, Proj Mgt, Inventory, Document Mgt.),G:(1.8TB)SQL Data. Plus 6TB mass storage standing by for Document Mgt. scan images; NAS Expansion and SQL data move if needed.
Vendor Sys. Analyst states that with 20 users he estimates we can expect to generate upwards of ~3TB data in about 3 years not including the document scans which go to shared storage separate.
Have read same “best practice: Move TempDB to its own Drive” on MSDN “Scaling Up Your Data Warehouse w/ SQL Server 2008″. However, I get the idea that this is for fairly substantial SQL environments.
I totally like your perspective on creating fixed TempDB files, according to # cores, separate partition all plays to my sense of order. BTW – Our vendor’s System Analyst says all this is foreign to him…
Here’s the question: How do I really determine whether or not (given the growth input I have from the vendor Systems Analyst) to use AUTOGROWTH with a single TempDB or implement multiple fixed, and calculate what size the fixed files should be?
And by the way, what is the naming convention used to keep multiple temp files “staight”?
Mind you we do about 1200 construction jobs a year and 3 years is nothing, this is a very document intensive business and every job generates the same data – its just a matter of scale be it a $25,000 job or a $10 million $ job.
And by the way, what is the naming convention used to keep multiple temp files “staight”? Can you use tempdb0, tempdb1, etc as simple as that or what?
Thank you for such a clear and valuable resource and any further light you can shed to help.
Sincerely, Tom W.
Hi, Tom. Even though this is a new app for YOU, it isn’t a new app for the vendor. Ask them to hook you up with other customers who have similar sizes to your company, and talk to their IT staff about their experiences with the application. When we’re talking 3 terabytes of data in 3 years, there’s no way for me to architect a blank-sheet system for you in a blog comment – I wish I had a fast & easy answer, but you’re talking about something that usually takes me 2-4 hours minimum, often 2-4 days.
You’ve got a lot of good questions in there, but with the quantity of questions, I think you’re going to be better off served by starting a relationship with a DBA or a consultant. I’m not trying to give you a sales pitch here, but just set expectations about what you can get on the web for free.
Brent,
Thanks for the quick reply. No worries mate! Have been in your shoes too many times (23 years consulting). Have been researching fast & furious but thought I’d ask. Already talking to local SQL consultants and have request in to vendor for other like GC end users. Appreciate your input. Will make this a regular stop for continuing education “on the fly” as I bring this new service to fruition.
All the best, Tom W.
Brent,
In Windows Server 2008 there are a variety of “Server Roles” that can be installed through the OS’s “Server Manager” tool. When installing SQL Server on this platform are there any of these roles that should be installed when it will be primarily a SQL Server platform?
Perhaps “Web Server (IIS)” if I’m installing Reporting Services?
Brendan – I don’t recommend using a SQL Server box for anything other than SQL Server. Given the licensing costs for SQL Server, if you need a web server or anything else, it’s best to put that on another box.
Good point regarding IIS but I was actually just trying to use that as an example rather than asking about that role in particular.
My understanding of the roles is that usually a server performs a particular function such as a file server, print server, application server etc. rather than just being a generic server doing 20 different tasks. (‘Cause that never happens, right?) So, for each particular function there is set of OS utilities/options that need to be configured. For example, if it’s a file server you have to set up shares, security on the shares, security on the folder (and whatever else I’m forgetting. I’m not a sysadmin!)
What I was wondering was if any of these roles were designed with an app like SQL Server in mind. My guess has always been that they could just be ignored because the SQL Server install program is designed to check for all the required components and install them if they are missing.
[...] any info available on the net when it comes to SQL Server. Just to give you a quick example: Brent Ozar and Jonathan Kehayas both have some neat articles about installing SQL Server. Of course, I use the [...]
Hi Brent
under “Configure SQL Server memory for best practices”,
you refer to AWE setting. Does this still hold true for Windows 2008 R2 ruunning SQL Servere 2008 R2?
Thanks
Jim – in that section, I say the following:
“First, that tricky checkbox that says “Enable AWE”. Check that box if you’re using a 32-bit server with more than 4 gigs of memory.”
There is no 32-bit version of Windows Server 2008 R2, so there’s your answer.
Oops !
got it
Tks
Jim
Just completed reading chapter-2 of the below book:
http://sqlservertroubleshooting.com/2009/12/sql-server-2008-internals-troubleshooting/
Memory settings is very very well explained in simple terms. Money well spent.
I will be a mini Brent once complete reading this book.
[...] looking up some info on DB Mail in SQL 2005, I came across a good post by Brent Ozar on some post install steps. It covered a few things I hadn’t thought [...]
[...] do this manually through the agent GUI or by running a script. Brent Ozar has a script in his SQL Server Setup Checklist Part 2 which you should follow when installing your SQL Server. The Time Matters SQL installer does a [...]
Thanks for the tips!
Mike Duncan
MCSD
I modify tempdb and logfiles with
use master
go
alter database tempdb modify file (name=’tempdev’, filename=’T:\MSSQL\DATA\tempDB.MDF’, size = 1mb)
go
alter database tempdb modify file (name=’templog’, filename=’L:\MSSQL\LOGS\templog.LDF’, size = 1mb)
go
then i create additional tempdbs and log file, my question is; should i delete the files i created of 1mb? or what shoul i do?
Ignacio – I’m not sure I understand the question. Can you rephrase it?
I set up a server 2008 standard 64 bits with 8 gb of ram. I created the partitions T for tempdb and L for logs, then i created the files using:
use master
go
alter database tempdb modify file (name=’tempdev’, filename=’T:\MSSQL\DATA\tempDB.MDF’, size = 1mb)
go
alter database tempdb modify file (name=’templog’, filename=’L:\MSSQL\LOGS\templog.LDF’, size = 1mb)
go
then i created created tempdb files depending on my cpu cores:
USE [master]
GO
ALTER DATABASE [tempdb] ADD FILE ( NAME = N’tempdev2?, FILENAME = N’T:\MSSQL\DATA\tempdev2.ndf’ , SIZE = 10GB , FILEGROWTH = 0)
GO
i did the same with the log, but i see that I have 1 file tempdb with 1mg and 4 with 5 gb, may i delete the dbfile of 1mb and the log file of 1mb i created initially? as to memory.. what should be my min memory and max memory taking into account i have 64 bits and 8 gigs? no awe?
Hmm – based on what it looks like you’re doing, you’re adding additional files rather than replacing the ones you’ve already got. By adding more files, you’re not getting rid of the initial ones.
hello, someone has a format or template to present a technical report of a server regarding os and sql diagnostic.
server windows 2008 sql 2008 standard, what is the consumption of memory per user? if i connect users through terminal server what is the memory consumption and bandwidth consumption of the server with windows 2008 and sql installed? thank you
Sorry, I don’t have a number for that – it would depend on what services you start on each user’s login, what build of SSMS they’re using, if they’re using any SSMS plugins, etc.
You mention setting up alerts for sev 16-25, but sev 16 is “other user fixable errors” isn’t it?
Are there particular errors that come through as a 16 that we don’t want to miss, or is 17-25 better?
I ask because after configuring 16-25 on a box our alerts system was flooded with Sev16′s for “DESCRIPTION: An exception occurred while enqueueing a message in the target queue. Error: 15404, State: 19. Could not obtain information about Windows NT group/user…”
I admit this was an issue that needed to be brought to light, but the system owner is questioning if we need email alerts for such messages or not.
What are your thoughts on Sev 16 specifically?
Thanks!
Andy – I think you actually answered your own question when you said, “I admit this was an issue that needed to be brought to light..” Bingo! There’s your answer.
Oh, and also – you can set a limit on how often an email is sent for any particular error. My scripts set it at 1 minute IIRC.