Professional Documents
Culture Documents
www.linkedin.com/in/srinivas-merugu-dba-azure
1. Firstly we have to check which file is full. Data File Full Or Log File Full
and troubleshoot according that
Use tempdb
Go
sp_spaceused
OR
SELECT SUM(unallocated_extent_page_count) AS [free pages],
(SUM(unallocated_extent_page_count)*1.0/128) AS [free space in MB]
FROM sys.dm_db_file_space_usage;
ssms.
➢ Try to connect it through query analyzer
➢ check for the log-reuse_wait_desc column of Tempdb Database
using syntax
Select [name], log_reuse_wait_desc from sys.databases where
name =’Tempdb’
1
Srinivas Merugu
www.linkedin.com/in/srinivas-merugu-dba-azure
2
Srinivas Merugu
www.linkedin.com/in/srinivas-merugu-dba-azure
OR
select * from sys.dm_exec_requests where session_id > 50
OR
Sp_who2 or sp_who2 active
If any transaction is not running then log file will be shrink
DBCC shrinkdb(‘tempdb’,’size’)
8. Try to shrink the Data File of Tempdb (if no OPEN transactions are in
progress).
Here first you have to verify the tempdb files location by using the below
command.
Use Tempdb
sp_helpfile or sp_helpdb ‘Tempdb’
After that you can use the below query to shrink the log or data file.
Note: You can shrink the tempdb data file for production server during
non-business hours (advisable).
USE [tempdb]
DBCC SHRINKFILE (N'templog' , 0)
Or
USE [tempdb]
DBCC SHRINKFILE (N'tempdev' , 8)
If we have multiple datafiles and shrink all files in single query window
in chunk basis.
9. If you are not able to release space from TempDB because entire Space in
TempDB will be unallocated space, Try the below T-SQL
USE TempDB
GO
DBCC FREEPROCCACHE /*Clears the procedure cache*/
Command will clear the procedure cache in memory. There is a risk involved with this, it can affect
next procedures to be reparsed and compiled. Also it might not give accurate results for DMV's.
3
Srinivas Merugu
www.linkedin.com/in/srinivas-merugu-dba-azure
DBCC DROPCLEANBUFFERS /*Forces all dirty pages for the current database to be written to disk
and cleans the buffers*/
DBCC FREESYSTEMCACHE ('ALL') /*Releases all unused cache entries from all caches*/
11. Final option is restart the instance once got approval . So new TempDB
will be creating.
Start->run->configuration manager->select services->Right click on
instance->restart.