I'm trying to execute the following script in SQL Server Management Studio:
USE [master]
GO
CREATE DATABASE [test1] ON PRIMARY (
NAME = N'test1',
FILENAME =
N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\test1.mdf',
SIZE = 70656KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB)
LOG ON (
NAME = N'test1_log',
FILENAME =
N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\test1_log.ldf',
SIZE = 164672KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
But I'm getting the error:
Msg 5123, Level 16, State 1, Line 2
CREATE FILE encountered operating system error 5 (Access is denied.)
while attempting to open or create the physical file
'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\test1.mdf'.Msg 1802, Level 16, State 4, Line 2
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Already have all role permissions for my user, any ideas on what's wrong?
services.msc). Then ensure that this account has access to this directory. Finally, if this is Vista/Win7 with UAC enabled, try opening SSMS as Administrator (rt-click). – swasheck Aug 09 '12 at 20:43CREATE DATABASE [test1]; GO? – swasheck Aug 09 '12 at 21:03