October 25, 2016 at 8:18 am
Folks
I have the AdventureWorks2012_Data.mdf file with me.
Will this be sufficient for me to install the DB on my local machine ?
If so what will be the command that I should run ?
The file is on C:\Users\moldin\Desktop directory now. I have SSMS installed ( I am also in the adminsitrators group in my PC )
October 25, 2016 at 8:28 am
CREATE DATABASE AdventureWorks2012
ON (FILENAME = 'c:\sqlserver\AdventureWorks2012_Data.mdf')
FOR ATTACH_REBUILD_LOG ;
Assuming you move the MDF to the above location. Should be ok.
October 25, 2016 at 11:35 am
I get an error....
Msg 5105, Level 16, State 2, Line 1
A file activation error occurred. The physical file name ' C:\Users\xxxxx\Desktop\AdventureWorks2012_Data.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation.
October 25, 2016 at 11:47 am
What's the result if you run this?
SELECT @@VERSION
October 25, 2016 at 11:47 am
So I put my MDF in a folder on the C drive called sqlserver and it has permissions to access it. If you do the same it should work.
October 25, 2016 at 11:57 am
Reply to LUIS
Microsoft SQL Server 2012 - 11.0.2100.60 (X64)
Feb 10 2012 19:39:15
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
October 25, 2016 at 11:59 am
REPLY TO BLOB
CREATE DATABASE AdventureWorks2012
ON (FILENAME = ' C:\AdventureWorks2012_Data.mdf')
FOR ATTACH_REBUILD_LOG;
Here is the error msg
Msg 5105, Level 16, State 2, Line 1
A file activation error occurred. The physical file name ' C:\AdventureWorks2012_Data.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation.
October 25, 2016 at 12:09 pm
Folks read this please. ( 10/25/2016 2.09 PM )
Earlier I had a extra space in the path so that was reasonable for SQLServer to say could not find file ...
Now I put the file in a place that had other mdf files. I think the syntax needs some clarification
Reply to LUIS and BLOB
CREATE DATABASE AdventureWorks2012
ON (FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Binn\Templates\AdventureWorks2012_Data.mdf')
FOR ATTACH_REBUILD_LOG;
Now I get
File activation failure. The physical file name "C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\AdventureWorks2012_Log.ldf" may be incorrect.
Msg 5123, Level 16, State 1, Line 1
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\MSSQL11.MSSQLSERVER\MSSQL\Binn\Templates\AdventureWorks2012_log.ldf'.
Msg 1813, Level 16, State 2, Line 1
Could not open new database 'AdventureWorks2012'. CREATE DATABASE is aborted.
October 25, 2016 at 12:16 pm
Reply to BLOB and LUIS
DONE! WORKED!
CREATE DATABASE AdventureWorks2012
ON (FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data\AdventureWorks2012_Data.mdf')
FOR ATTACH_REBUILD_LOG;
TRICK: - The file had to be in this folder. ( I got this folder by checking YOUTUBE video )
WORKS WORKS WORKS!
October 25, 2016 at 12:17 pm
This is the output I get in response to the command...
File activation failure. The physical file name "C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\AdventureWorks2012_Log.ldf" may be incorrect.
New log file 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data\AdventureWorks2012_log.ldf' was created.
Converting database 'AdventureWorks2012' from version 705 to the current version 706.
Database 'AdventureWorks2012' running the upgrade step from version 705 to version 706.
October 25, 2016 at 12:25 pm
I was just going to mention that folder. I'm glad that you were able to attach the db successfully.
Remember that SQL Server has different credentials than your user account. That's why handling files need special care when doing it through SQL Server.
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply