database files movement from one drive to another drive in sql server
Get link
Facebook
X
Pinterest
Email
Other Apps
1) Capture the .mdf and ldf file namesof that particular datbase to which you want tomoveSELECT*FROM sys.master_files
2) Ensure that you have latest .BAK file available forrollback plan
3) Take that particular database alone into OFFLINE
ALTERDATABASE database_name
SET OFFLINE
4) Move the files tonewlocation5) Run the below command make changes atsystem catlogue level
USE master
GOALTERDATABASE AdventureWorks2012
MODIFY FILE( NAME = AdventureWorks2012_Log,
FILENAME ='C:\NewLoc\AdventureWorks2012_Log.ldf');
GOALTERDATABASE AdventureWorks2012
MODIFY FILE ( NAME = AdventureWorks2012_Data,
FILENAME ='C:\NewLoc\AdventureWorks2012_data.mdf');
6) Bring the database ONLINE
ALTERDATABASE database_name
SET ONLINE
7)Once the database came online run the below commmand to chek whether the new path appearing at catlogue levelSELECT name, physical_name AS CurrentLocation, state_desc
FROM sys.master_files
WHERE database_id = DB_ID(N'<database_name>');
We can run below PowerShell and SQL Server commands when we want to find ou when the failover has happened. cls Get-winEvent -ComputerName ListerNameHere -filterHashTable @{logname = 'Microsoft-Windows-FailoverClustering/Operational' ; id = 1641 } | Where-Object { $_ . Timecreated -like '*05/09/2020*' } | Format-Table -AutoSize -Wrap <# 35201-->timeout alert run this by changing -LogName to System 41-->41 is power shutdown run this in system #> clear Get-EventLog -LogName Application -After ( Get-Date ) . AddHours( -48 ) | Where-Object { $_ . EventID -in ( 1100 , 1074 , 35201,41,1561,7024,1135,7032,1146 )} | Format-Table -AutoSize -Wrap cls Get-EventLog ` -LogName System |Where-Object{$_.EventID -in (1054,1053,1055,1138,1141,1142,5140,5142,1559,1560,1563,1588,1068,5144,1562,5143,5168,1564,1177)}|Format-Table -AutoSize -Wrap EXEC sp_readerrorlog 0,1,'lease worker' EXEC sp_readerrorlog 0,1,'...
When I see the 'OLDEST_PAGE' in log_reuse_wait_desc column and not allowing to me to shrink the log file of database I followed the below steps 1) When you see 'OLDEST_PAGE' run CHECKPOINT on that particular database 2) Take the Transaction log backup of that particular database 3) Try to shrink the log file of database These steps worked for me when I encountered this issue in my environment.
Comments