On this page:
Introduction
Using "SQL Server Management Studio"
Using "SQLCMD.EXE
Starting a SQL Instance in a Command-Prompt Window.
| Introduction | Microsoft SQL Server's heavy use of temporary files can result in an I/O performance bottleneck. The non-persistent files used by SQL to store system data are called 'tempdb', and are literally a temporary database consisting of two files: one a table file, the other a log file. Moving these files to a high-performance storage device, such as a RAM disk, can dramatically improve SQL Server performance. Because the files are truly temporary -- they are, in fact, re-created each time SQL is started -- there is no requirement that these files be located on a persistent storage device. | |||||||||||||
To move the tempdb files from their current location to a higher-performance storage device requires that the SQL Server instance be running and that it execute several queries. Outlined below are two sets of query commands. The first set changes the locations of the temporary database and log files (tempdb.mdf and templog.ldf). The second set reports the file location settings.
These query commands can be executed by the SQL instance using the "SQL Server Management Studio" graphical user interface tool, or using the SQLCMD.EXE command-line tool. Examples are provided for both tools. |
||||||||||||||
| Using "SQL Server Management Studio" |
|
|||||||||||||
| Using SQLCMD.EXE | To change the location using the command-line tool SQLCMD.EXE, open a command-prompt window with Administrator privileges, and cd to the instance's Binn directory. Then follow one of the three methods shown below:
|
|||||||||||||
First Method: Scripted |
Create the two script files, 'ChangeLocation.sql' and 'ReportLocation.sql', with the content shown in the tables above. Modify the file path specification appropriately. To execute the scripts, open a command prompt and enter the commands shown below:
|
|||||||||||||
Second Method: Interactive |
Execute the commands in an interactive SQLCMD session, as shown below (modify the file path specification appropriately):
|
|||||||||||||
| Third Method: Command-Line Query |
The query commands can be concatenated for use in a single argument on the command line, as shown below (modify the file path specification appropriately):
|
|||||||||||||
| Starting a SQL Instance in a Command-Prompt Window | If the SQL instance fails to start as a service, it can be started in a command-prompt window. Generally, this is only done for troubleshooting purposes. (See http://msdn.microsoft.com/en-us/library/ms180965(v=SQL.100).aspx) For example, if a SQL instance starting up as a service cannot find the storage device that the tempdb files are to be stored on, the instance will fail startup. Since the service cannot be started, its tempdb location also cannot be reconfigured in the normal way. In this case, the solution is to run the instance in a command-prompt window, reconfigure the tempdb location, stop the command-prompt instance, and start it again, running as a service.
To start a SQL instance in a command-prompt window, cd to the instance's Binn directory (eg. 'C:\Program Files\Microsoft SQL Server\MSSQL10.SQL_INSTANCE\MSSQL\Binn'), and enter the following command: sqlservr -f -s "SQL_INSTANCE" This command runs the SQL instance named "SQL_INSTANCE" inside the command-prompt window itself, with a minimal configuration. A minimal configuration limits instance execution to a single user. To reconfigure the tempdb file locations, open another command-prompt window and use one of the SQLCMD.EXE methods shown above. When finished, return to the command-prompt window in which SQL is running, type Ctrl-C, and confirm the shutdown request. Afterward, run the SQL instance as a service. |
|||||||||||||
| See also: Optimizing tempdb Performance Microsoft SQL Server Performance Solutions |
||||||||||||||
Last updated July 7, 2010
![]() |
| Home | - | Site Map | - | Contact Us | - | Legal Notices | - | Privacy Policy |
SuperSpeed LLC is the owner of the following U.S. Patents 5577226, 5606681, 5918244, 6370615, 6629201, 6651136, 7017013, 7039767, 7111129, 7475186, 7594068, 7631139, 7886099 and other patents are pending.
Copyright © 1996-2012 SuperSpeed LLC. All rights reserved.