Users Pricing

forum

Home Forums How to copy the data of mdf to another mdf file in sql server – MindStick

How to copy the data of mdf to another mdf file in sql server

Anonymous User 4516 16 Jul 2013
Hi developers!

I am stucking on one place in sql server. We have more than 100 of databases(.mdf). I want to copy the updated data in mdf file to another location. Suppose First time have I have detach all databases from location C:\Program Files (x86)\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA and copy them to another location say C:\ and reattach the all original files(detach because of used by sql server). Now I have copy in C drive. I want a query or steps to copy the updated data from all databases from my original location to copied location (which is in c drive) regularly. I have googled about this and find the solution that stop your services first. But I can't do this because in my company 24 hours shift and regularly data updated. So there is no chance to do this. and also I have tested it with Batch file.

xcopy /y /d /r /s /e "C:\Program Files (x86)\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\TestAxle.mdf" "c:\TestAxle.mdf" 

But it showing the error message Sharing Voilation also tested with the below command:

copy /y "C:\Program Files (x86)\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\TestAxle.mdf" "c:\TestAxle.mdf" 

But its also showing the file is using by another process.
Please tell me how do I copy the updated data in mdf file regularly.

Thanks in Advance 


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md