Category Archives: SQL Server

Chnage the Path for the mdf and ldf file while Creating a SQL Database

To change the default path for mdf and ldf files in SQL ServerUSE [master] GO EXEC xp_instance_regwrite N’HKEY_LOCAL_MACHINE’, N’Software\Microsoft\MSSQLServer\MSSQLServer’, N’DefaultData’, REG_SZ, N’F:\Data\DB05′ GO EXEC xp_instance_regwrite N’HKEY_LOCAL_MACHINE’, N’Software\Microsoft\MSSQLServer\MSSQLServer’, N’DefaultLog’, REG_SZ, N’F:\Data\DB05′ GO Advertisements

Posted in SQL Server, Uncategorized | Leave a comment

The file ‘F:\data\DB05_log.ldf’ cannot be overwritten. It is being used by database ‘test’.

First I took a backup of DB05BACKUP DATABASE DB05 TO DISK=’F:\backup\DB05_20190131.BAK’ WITH INITThen I restored this DB05 as test RESTORE DATABASE test from DISK=’F:\backup\DB05_20190131.BAK’ WITH RECOVERYMy test DB is working fine. But when I am trying to Restore the same … Continue reading

Posted in SQL Server | Leave a comment