Monday, May 6, 2013

Copy Sql server database files(MDF and LDF) without stopping SQL Server services


The better approach for transferring database is to take a backup of database and move backup file anywhere but even if you wish to copy MDF and  LDF file, you can have above approach. If you are using your database, you are not able to copy the data or log files.For copying these files you need to stop sql services but  you can do it without even stopping services of SQL with following small script.

 ALTER DATABASE <Databasename>
 SET OFFLINE WITH ROLLBACK IMMEDIATE;

 It's not good but better than stopping SQL Server services
ALTER DATABASE <Databasename> SET ONLINE;

No comments :

Post a Comment