Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
306 views
in Technique[技术] by (71.8m points)

sql server - Cannot install adventureworks 2012 database - Operating system error 5: Access is denied

I am trying to install AdventureWorks 2012 database in sql server 2012. I got the mdf file from this link - http://msftdbprodsamples.codeplex.com/releases/view/93587

Here is the name of the file I downloaded - AdventureWorks2012_Database.zip

I am doing all this on a windows 7 64 bit.

I get the error below:

Attach database failed for Server 'SuperPCSQL2012'.  (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=11.0.2100.60+((SQL11_RTM).120210-1917+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476

ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

Unable to open the physical file "C:DatabasesAdventureWorks2012_Data.mdf". Operating system error 5: "5(Access is denied.)". (Microsoft SQL Server, Error: 5120)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=11.00.2100&EvtSrc=MSSQLServer&EvtID=5120&LinkId=20476
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The reason for the problem - Putting the database mdf and ldf files in a directory outside the "official" SQL server installation folder.

Solution -

http://tryingmicrosoft.com/error-while-attaching-a-database-to-sql-server-2008-r2/

Paste your .mdf file and ldf file in this directory - C:Program FilesMicrosoft SQL ServerMSSQL11.SS2012MSSQLDATA

Solutions that did NOT solve the problem -

1 - Unblocking the zipped files. Also checked that mdf and ldf files are not blocked. (Steps - right click zip file > properties > unblock)

Unblock

2 - Run SSMS 2012 as administrator.

3 - Run SQL query of the form -

CREATE DATABASE MyAdventureWorks 
    ON (FILENAME = 'C:MySQLServerAdventureWorks_Data.mdf'), 
    (FILENAME = 'C:MySQLServerAdventureWorks_Log.ldf') 
    FOR ATTACH; 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...