How to move a Logfile to another location

— If you need to move a logfile onto another harddrive, you can do it this way.

USE master
GO

— If this command just keeps running, then it properly is because there is connection against the database

ALTER DATABASE <Databasename> SET SINGLE_USER
GO

SP_DETACH_DB ‘<Databasename>’
GO

— Now you can move the log file to the new location.
/*XP_CMDSHELL ‘COPY <source location\filename> <destination location\filename>*/

SP_ATTACH_DB ‘<Databasename>’, ‘<Data filename>’, ‘Log filename’
GO

Dette indlæg blev udgivet i SQL Server - scripts. Bogmærk permalinket.