Attach databases from old hardware

  • Hi all!

     

    I had to drop my old PC, and change to a new laptop.

    Most databases i have as backups, and that runs without any problems.

    On some, I only have the .mdf file, and have tried to attach to it.

    My first try was to copy to c:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\, but that was not poosible.

    Next was to copy ro C:\temp, and attach from there.

    Got error 5120/error 5

    Found some support, that said, that i should give full rights to the .mdf field, via NT Service\MSSQL$SQL2017

    When I changed to  NT Service\MSSQL$ I got some different possibilities, and i added them with full control one by one, but still no joy.

    How to?

    Microsoft SQL Server Management Studio 11.0.2100.60

    Microsoft Data Access Components (MDAC) 10.0.17763.1

    Microsoft MSXML 3.0 6.0

    Microsoft Internet Explorer 9.11.17763.0

    Microsoft .NET Framework 4.0.30319.42000

    Operating System 6.3.17763

  • Not sure, what do you mean by PC. I hope it is a test case and learning.

    It is like a migration - You need SQL service in your new machine and you can start migrate it.

    Are you mounting the same storage Or two machines having dedicated storage?

    Muthukkumaran Kaliyamoorthy
    https://www.sqlserverblogforum.com/

  • Error 5 is access is denied.  My first step would be to check what user the SQL Server service is running under and make sure that account has permissions.

    If this is running on your own computer with your own credentials with nobody except you accessing the database, there should be little to no risk in granting "everyone" full control over the database.  This should get you around the access is denied.

    The above is all just my opinion on what you should do. 
    As with all advice you find on a random internet forum - you shouldn't blindly follow it.  Always test on a test server to see if there is negative side effects before making changes to live!
    I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.

  • Mr. Brian Gale wrote:

    Error 5 is access is denied.  My first step would be to check what user the SQL Server service is running under and make sure that account has permissions.

    If this is running on your own computer with your own credentials with nobody except you accessing the database, there should be little to no risk in granting "everyone" full control over the database.  This should get you around the access is denied.

    Mr. Brian Gale wrote:

    Error 5 is access is denied.  My first step would be to check what user the SQL Server service is running under and make sure that account has permissions.

    If this is running on your own computer with your own credentials with nobody except you accessing the database, there should be little to no risk in granting "everyone" full control over the database.  This should get you around the access is denied.

     

    Looks at this:

    https://stackoverflow.com/questions/18286765/sql-server-operating-system-error-5-5access-is-denied

     

     

    Muthukkumaran Kaliyamoorthy
    https://www.sqlserverblogforum.com/

  • You should be able to place the file(s) in the ..\Data folder under the instance in C:\Program Files\.  If you cannot put the files in that location then you need to find out why you don't have permissions to that location.

    If the reason you don't have permissions to that location is because of group policy - you need to follow up with your IT department to find out how to get that access.

    For SQL Express on a PC - the location you are using is where the data/log files should be located - although you can place them in other locations.  If you want to place them in a different location - create a new folder...do not use C:\Temp or C:\Windows\Temp.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply