The script pasted below was provided to us by our professor. He wants us to use this script to create a DB, but there is an issue. When I run this script. I get an error.

Msg 5133, Level 16, State 1, Line 4
Directory lookup for the file "C:\Program Files\Microsoft SQL Server\MSSQL15.SQLEXPRESS\MSSQL\DATA\WonderfulWheels.mdf" failed with the operating system error 3(The system cannot find the path specified.).

Msg 1802, Level 16, State 1, Line 4
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

I understood where the issue was, but I'm unable to solve it.

Code problem area:

( NAME = N'WonderfulWheels', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL15.SQLEXPRESS\MSSQL\DATA\WonderWheels.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB )
( NAME = N'WonderfulWheels_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL15.SQLEXPRESS\MSSQL\DATA\WonderWheels_log.ldf' , SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB )

I don't have a similar file path as mentioned in this script, as I don't understand what these filenames are like. Do I need to generate that file path on my own? Some guidance, please.

In the SQL Server 2019 folder, I got two subfolders, licenses and common7.

I looked around for solutions and did not understand any of them.

  • 2
    Find the full path of your own MSSQL\DATA folder and use that in your script. Alternatively, I believe it's possible to skip the FILENAME field entirely and leave SQL Server to create them.
    – Martheen
    Commented Nov 19, 2023 at 2:32
  • It won't create the directory structure, only the files. I'd advise you to just use the default directory, so just FILENAME = N'WonderWheels.mdf' Commented Nov 19, 2023 at 2:42
  • 1
    Are you sure you're looking in the right place? The presence of a Common7 folder suggests that you're actually looking at an SQL Server Management Studio (SSMS) folder (e.g.: C:\Program Files (x86)\Microsoft SQL Server Management Studio 19\Common7) instead of the SQL Server folder. SSMS is a tool for connecting to and managing SQL Server instances, not itself a database system. Have you actually installed an instance of SQL Server 2019? If so then what's the output of SELECT @@VERSION? Commented Nov 19, 2023 at 5:44
  • 1
    Run SELECT physical_name FROM master.sys.database_files to see where those files are stored. Commented Nov 19, 2023 at 6:03
  • 1
    Run this query to determine the default file paths for the instance and use those directories:. SELECT SERVERPROPERTY('InstanceDefaultDataPath') AS DefaultDataPath, SERVERPROPERTY('InstanceDefaultLogPath') AS DefaultLogPath;
    – Dan Guzman
    Commented Nov 19, 2023 at 11:25

1 Answer 1


script you provided seems to be attempting to create a database in a specific file location on your SQL Server instance. error message indicates that its unable to locate or access the specified file paths to create the database files.

when youre setting file paths for your database files like.mdf and .ldf you need to make sure that the paths exist and are accessible by the SQL Server service account.

if you're not sure about the appropriate file paths or if those paths don't exist on your machine, you can modify the script to use default paths or specify paths where your sqsl server instance has access to create the database files.

    NAME = N'WonderfulWheels', 
    FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL15.SQLEXPRESS\MSSQL\DATA\WonderfulWheels.mdf',
FILEGROUP [WonderfulWheels_log_group] CONTAINS LOG
    NAME = N'WonderfulWheels_log',
    FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL15.SQLEXPRESS\MSSQL\DATA\WonderfulWheels_log.ldf',
    SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.