Mit folgenden paar Zeilen vbs Code, lassen sich automatisch alle Transaktionslogs der Datenbanken auf dem MSSQL Server verkleinern:

set sql = createobject(“adodb.connection”)
sql.open(“driver={SQL Server};server=localhost;uid=sa;pwd=*******;database=master”)
set r = sql.execute(“sp_databases;”)
while not r.eof
   set sql_temp = createobject(“adodb.connection”)
   sql_temp.open(“driver={SQL Server};server=localhost;uid=sa;pwd=*******;database=”&r(“DATABASE_NAME”))
   set s = sql_temp.execute(“SELECT FILE_NAME (2) as filename;”)
   sql_temp.execute(“BACKUP LOG “&r(“DATABASE_NAME”)&” WITH TRUNCATE_ONLY;”)
   wscript.echo r(“DATABASE_NAME”)
   sql_temp.execute(“DBCC SHRINKFILE(“&s(“filename”)&”,0);”)
   wscript.echo r(“DATABASE_NAME”) & ” ” & r(“DATABASE_SIZE”)/1024 & ” MB”
   set sql_temp = nothing
r.movenextwend
set sql = nothing

Share