title: How to copy the data of mdf to another mdf file in sql server
body: <p>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 <b> C:\Program Files (x86)\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA </b> and copy them to another location say <b> C:\ </b> 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 regulary data updated. So there is no chance to do this. and also I have tested it with Batch file.</p>
  
  <pre>xcopy /y /d /r /s /e "C:\Program Files (x86)\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\TestAxle.mdf" "c:\TestAxle.mdf" </pre> 
  
  <p>But it showing the error message <b>Sharing Voilation</b>
  also tested with the below command:</p>
  
  <pre>copy /y "C:\Program Files (x86)\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\TestAxle.mdf" "c:\TestAxle.mdf" </pre> 
  
  <p>But its also showing the file is using by another process.
  <br/><br/>
  Please tell me how do I copy the updated data in mdf file regularly.</p>
  
  <p>Thanks </p>