To compress stored procedures for all library logs in Sqlserver2005 _mssql

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.