How to move MDF/NDF for a Replicated Database

Chris Skorlinski
Microsoft SQL Server Escalation Services

Here is another customer question about Replication I thought worth sharing.

I am using SQL Server 2008 64 bits. I have to change the location of the data file (i.e. MDF file). I was planning to  detach and attach. DB is also using Transactional Replication so I can’t detach the DB. Is there any way I can change the location of data file (i.e. MDF file) while DB is using transactional replication?

Instead of detach and attach WITH MOVE to change a database MDF/NDF location you can use the ALTER DATABASE  <db name> MODIFY FILE.

http://msdn.microsoft.com/en-us/library/bb522469.aspx
MODIFY FILE ( NAME = logical_file_name, FILENAME = ' new_path/os_file_name ' )