0

We had a server running Microsoft SQL Server 2014 databases on Hyper-V. I exported it (with C: and D: drives) and opened on other machine.

I could not start the MSSQLSERVER service because it said the master db needed to be rebuilt.

I've rebuilt the master db, but now the databases are empty, I cannot see databases except master, model, msdb, and tempdb.

I have all databases (mdf and ldf files) in this folder D:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA. How to restore them and not lose all functionality?

Paul White
95.4k30 gold badges440 silver badges689 bronze badges
asked Nov 15, 2020 at 16:39
2
  • Did you migrate and attach the volume (VHD) that represents the D drive of the VM as well? Commented Nov 15, 2020 at 16:54
  • Yes I did. C and D drives Commented Nov 15, 2020 at 17:01

1 Answer 1

2

I have all Databases (mdf and ldf files) in this folder D:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA how to restore them and not lose all functionality?

When you rebuild master, it loses track of where the user databases are. You just need to attach them, and recreate the logins for any orphaned users.

And also consider linked servers, scheduled jobs and everything else which is stored outside the user databases and was scratched by the rebuild.

Tibor Karaszi
18.3k2 gold badges17 silver badges30 bronze badges
answered Nov 15, 2020 at 17:00
4
  • The thing is, that admin credentials cannot contact domain controller and let me into SQL server. It is maybe off-topic. And other credentials have no rights to attach or recreate logins. My brain just thinks only to clone DC. Or are there no such brutal ways? Commented Nov 15, 2020 at 19:16
  • 1
    If you're logged on as a local administrator and can't connect to SQL Server as a sysadmin, follow the procedure here: learn.microsoft.com/en-us/sql/database-engine/configure-windows/…. If you can't contact the domain controller to authenticate, then that's a separate issue, but you can fix the SQL Server using a local admin account. Commented Nov 15, 2020 at 21:33
  • Do you have enough privileges to use SQLCMD? support.atandra.com/article/…. If privileges are the problem you have to fix that first: contact your sysadmin. Commented Nov 17, 2020 at 15:17
  • You said "recreate the logins for orphaned users" The link "orphaned users" said "execute the following statement in the user database:" - what is user database? Where to execute this query? Commented Feb 21, 2021 at 20:03

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.