Thursday, January 5, 2017

SQL Server DBA - SHRINKFILE and TRUNCATE Log File in SQL Server

--SHRINKFILE and TRUNCATE Log File in SQL Server
SELECT

  DB_NAME(database_id) AS DatabaseName,

  Physical_Name,

  Name AS Logical_Name,  (size*8)/1024 SizeMB

FROM   sys.master_files WHERE  DB_NAME(database_id) = 'DHL_ETL'

GO
ALTER DATABASE DHL_ETL

SET RECOVERY SIMPLE WITH NO_WAIT;

GO

-- Shrink the truncated log file to 1 MB.

DBCC SHRINKFILE(DHL_ETL_log, 1);  --file_name is the logical name of the file to be shrink

GO

-- Reset the database recovery model.

ALTER DATABASE DHL_ETL

SET RECOVERY FULL WITH NO_WAIT;

GO

No comments:

Search This Blog

DAX - Grouping on multiple columns and the count

Please go thorugh the below URL for entire soultion. http://community.powerbi.com/t5/Desktop/DAX-Grouping-on-multiple-columns-and-the-cou...