I set up a Windows Server 2012 virtual machine exactly the way we want it. I shut down the instance, made a copy of the .vhdx virtual drive, then spun up a new VM and attached the copy of the drive.
I started up the new VM and everything worked properly. Then I proceeded to run SysPrep on the new VM so it wouldn't clash with the original and I could run them both at the same time.
After running Sysprep I had to enter a CD-Key when I powered up the instance (expected behavior) and had to create an account for the new VM.
SQL Server Express was still installed and I was able to connect. However, whenever I try to expand a database I get an error message The database [DbName] is not accessible. (Object Explorer)
I also noticed that the SQL users I had created are now gone.
Does anyone know why this happened or how to recover?
The machine name gets changed during sysprep and SQL Server needs to be manually made aware of this. Try running this with
sysadmin
privileges:and then restart the SQL Instance. For SQL Express you will most likely need to replace
instancename
withsqlexpress
.Here is the TechNet article explaining renaming a host.