Question

I keep getting "file is open in another program" when i try to copy LDFs from one production to dev. Is there another way to copy these ldfs to dev server?

Was it helpful?

Solution

You'll need to stop the SQL Server Service, or take the DB offline in order to copy the LDF files. SQL will maintain an open file handle to the LDF as long as the DB is up and running.

You could always just restore a DB backup to Dev and run any trans log backups to roll the DB forward. That's what I'd recommend actually over copying LDFs to a different server.

OTHER TIPS

Take a step back and ask, why are we copying log files? SQL Server LDF files contain transaction log data, but they're not terribly useful by themselves. To work with a database, you need both the data files and log files. In order to access those files directly via the file system, though, you'll either need to stop SQL Server or use snapshot technologies like VSS.

If you're trying to synchronize transactions across multiple databases, check out technologies like transactional replication.

If you're trying to back up the database, use the SQL Server BACKUP DATABASE command.

Just to add to the list of methods:

You can also detach your DB and then copy the files. Tip: Before you detach your DB run sp_helpdb 'db_name' to find the location of your data/log files.

If you don't want to roll back your database to a point in time and you don't need transaction history - creating a database from a database backup will be just fine. You can check wheter your database is in Simple recovery model. If it is, then you don't need transaction history and can go with recovery from database backups.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top