# Windows Server 2012 Hyper-V Rename - SQL DB Issues

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:

sp_dropserver <old_name\instancename>;
GO

and then restart the SQL Instance. For SQL Express you will most likely need to replace instancename with sqlexpress.
I was able to log in as sa and run your recommended stored procedures to rename the instance. I still had the same issue when I use Windows Authentication and try to explore the database. The DBs show up, but when you go to expand they throw the error. There are only 2 users listed in the Security section. However, I logged in as sa and could explore everything and see all the users. Simply added a new user with the correct machine name with sysadmin privileges and it worked like a charm. Thanks. – Sam Oct 14 '13 at 22:06