Is there a way to be faster?
Is there a way to shrink all databases at once?
Copy Code code as follows:
ALTER DATABASE name
Set Recovery simple
Go
DBCC SHRINKDATABASE (database name)
Go
ALTER DATABASE name
Set Recovery full
Go
There is also a compression log tool, a B/s interface form of operation compression database, is in the selection of the database when the old need to select a specific library, and a large number of databases, some libraries were compressed, and did not automatically sort; Currently need is the compressed database automatically rolled to the last side, each Drop-down list is always open to the largest log record of that library, this easy to implement, the requirement is to perform log compression, execution speed faster?
How to optimize? Is there a way to compress all the libraries at once?
A one-time compression of all databases through stored procedure implementations: testing through in Sqlserver2005
Copy Code code as follows:
CREATE PROCEDURE Shrinkdatabase
as
declare @name nvarchar (2000)
Declare getdatabasecursor cursor for
Select name from sysdatabases//Remove all library names
Open getdatabasecursor
F Etch next from Getdatabasecursor
into @name//to place the values taken out in a variable
while @ @fetch_status = 0////////////////////////// Br>exec (' ALTER DATABASE ' + @name + ' Set recovery simple ')
Exec (' DBCC SHRINKDATABASE (' + @name + ') ')
EXEC (' alter Database ' + @name + ' Set recovery full ')
fetch next from Getdatabasecursor
to @name end
Close Getdatabas Ecursor//Off
deallocate getdatabasecursor//release
sp_helpdb urltest//ratio to database size
Exec shrinkdatabase//execution