1

I am using SQL Server 2014 and I am trying to create a database with this command

CREATE DATABASE [EFSDB]  
ON (NAME = N'EFSDB_Data', FILENAME = N'$MDF', SIZE = 2, FILEGROWTH = 10) 
LOG ON (NAME = N'EFSDB_Log', FILENAME = N'$LDF' , SIZE = 2, FILEGROWTH = 10%)

However, I am getting this error:

A file activation error occurred. The physical file name '$MDF' may be incorrect. Diagnose and correct additional errors, and retry the operation.

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

This command works in SQL Server 2008 but doesn't work in SQL Server 2014. This command is saved in sample.sql file and that file gets executed using the below command:

C:\Program Files\Microsoft SQL Server\120\Tools\Binn\OSQL.EXE" -S ServerName -E  -i Sample.sql
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
subbu
  • 3,229
  • 13
  • 49
  • 70
  • You should also explain what you are trying to do, not just how you are trying to do it. Are you executing this in SSMS or `sqlcmd`? The latter has `$(variables)`, and it seems like you may be trying to substitute another path where you write `$MDF`. But how would we know, without any context? – underscore_d Aug 14 '17 at 09:37
  • **STOP** using `osql` ! It's been deprecated since SQL Server **2005** - use `sqlcmd.exe` instead! – marc_s Aug 14 '17 at 09:55
  • Take a look on permissions for the Data file folder. – Abhay Dixit Aug 14 '17 at 10:05

0 Answers0