Home > SQL server DBA administration > Shrinking all the databases log file at a moment.

Shrinking all the databases log file at a moment.


In our day to day DBA job log file full error is common mater bit it is a very tedious job if a SQL instance hold lots of databases  and it is quite tough to figure out which database log file is full. The impact of log file full is very pathetic cause database can be suspected due to less space. To shrink the log file below I used one command which could be truncate the inactive space for all database within a minute. The script is not destroying the log chain so you can use in replication server also and configure as a SQL job

 

Shrink Command for all databases:

 

sp_msforeachdb “use [?];  dbcc shrinkfile(2,TRUNCATEONLY) WITH NO_INFOMSGS ”

 

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: