Published on

January 12, 2015

Understanding SQL Server Error Messages

Errors are a common occurrence when working with SQL Server. Whether you are a beginner or an experienced user, encountering error messages is a part of the learning process. In this blog post, we will discuss one specific error message and explore the concepts behind it.

One of the most common error messages that users encounter is “Msg 5133, Level 16, State 1, Line 2 Directory lookup for the file failed with the operating system error 2(The system cannot find the file specified.)”. This error typically occurs when creating a database and there is an issue with the file path.

However, there are cases where users receive this error message even when they are simply running the “Create Database” command without specifying a file path. This can be confusing and requires further investigation.

After researching and consulting with experts, it was discovered that SQL Server has a default path for database files. If no path is specified in the command, SQL Server will use this default path. This explains why users were encountering the error even without providing a file path.

To reproduce the error, one can modify the default path in the SQL Server registry settings. The registry value that controls the default path is located at:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL12.SQL2014\MSSQLServer

By changing the values in this registry key, you can simulate the error and observe the same error message. The error message will display the invalid file path that was set in the registry.

To view the current default data and log paths, you can use the following T-SQL query:

SELECT SERVERPROPERTY ('InstanceDefaultDataPath') AS [Default_Data_path]
SERVERPROPERTY ('InstanceDefaultLogPath') AS [Default_log_path]

If you want to change the default path using SQL Server Management Studio, you can do so by right-clicking on the server node, selecting “Properties,” and then navigating to the “Database Settings” tab. From there, you can modify the default data and log paths.

It is important to note that any changes made to the default path require a restart of the SQL Server service in order for the changes to take effect.

Understanding error messages and the underlying concepts can greatly enhance your troubleshooting skills when working with SQL Server. By exploring the causes and solutions to common errors, you can become a more proficient SQL Server user.

Click to rate this post!
[Total: 0 Average: 0]

Let's work together

Send us a message or book free introductory meeting with us using button below.