Good Day, I need to shrink log files of databases of the server,but there are too many databases and out of which only few has more space available which I need to shrink.
Is there any sql query which can give me the available free space of log files of all the databases and based on result I can shrink specific database log files which has more free space.
I am using sql 2008Rgds,
You can find the information in the DMV
A brilliant example of usage can be found on [Jonathan Kehayias' Blog]
You could then build some logic in t-sql to process the log files that you want to shrink.
However, you need to see why these logs have grown. If this came about through "normal" activity, then shrinking them will only cause them to grow again. If they need to be larger, leave them be. (Auto)Growing files can cause performance problems at the moment of growth and later on through file fragmentation.: http://sqlblog.com/blogs/jonathan_kehayias/archive/2009/06/06/getting-log-space-usage-without-using-dbcc-sqlperf.aspx
answered Jan 11 '11 at 01:35 AM
DBCC SQLPERF(LOGSPACE) This will return the logfile size in percentage then shrink the logfile based on your wishbefore shrinking try to truncate your log file which may resolve the issue using BACKUP LOG
answered Jan 11 '11 at 02:05 AM