Cannot specify a log file in a CREATE DATABASE statement without also specifying at least one data file.

Error Message:
Msg 188, Level 15, State 1, Line 2
Cannot specify a log file in a CREATE DATABASE statement without also specifying at least one data file.

Severity level:
15.

Description:
This error message appears when you try to specify a log file in a CREATE DATABASE statement, without specifying at least one data file.

Consequences:
The SQL statement cannot be parsed and further execution is stopped.

Resolution:
Error of the Severity level 15 are generated by the user and can be fixed by the SQL Server user. Either you remove the data log file specification or you specify at least one data file.

Versions:
All versions of SQL Server.

Example(s):
USE master;
IF DB_ID (N’MyExample’) > 0
 DROP DATABASE MyExample;
GO
CREATE DATABASE MyExample
LOG ON
( NAME = MyExample_Log,
    FILENAME = ‘MyExample_Log.ldf’,
    SIZE = 5MB,
    MAXSIZE = 25MB,
    FILEGROWTH = 5MB );
GO

Remarks:
In the above example we try to create the database MyExample and specify the MyExample_Log log file. Because we have not specified a data file, the error is raised.

]]>

Leave a comment

Your email address will not be published.