0
Shopping Cart
Toggle navigation
Services
My Services
Order New Services
View Available Addons
Domains
My Domains
Renew Domains
Register a New Domain
Transfer in a Domain
Billing
My Invoices
My Quotes
Mass Payment
Add Funds
Payment Methods
Support
Tickets
Knowledgebase
System Status
Open Tickets
0
Shopping Cart
Account
Login
Register
Forgot Password?
Portal Home
Knowledgebase
SQL db shrink code
SQL db shrink code
21/10/2018 16:07
Databases
--Select Count(name) from sysdatabases
declare @db as varchar(100)
set @db = 'db to be shrunk goes here'
BACKUP LOG @db
With Truncate_only
-- Set truncate truncate on checkpoint to true
EXECUTE sp_dboption @db, 'trunc. log on chkpt.', TRUE
-- Checkpoint to truncate the inactive part of the transaction log
CHECKPOINT
-- Shrink Database with the specified % Free Space
DBCC SHRINKDATABASE (@db, 10)
-- Shrink file with the specified ID
DBCC SHRINKFILE(1)
-- Set truncate truncate on checkpoint to true
EXECUTE sp_dboption @db, 'trunc. log on chkpt.', FALSE
Print
Share via
Comments
Please login to comment
×
Close
Loading...
×
Choose language
العربية
Azerbaijani
Català
中文
Hrvatski
Čeština
Dansk
Nederlands
English
Estonian
Persian
Français
Deutsch
עברית
Magyar
Italiano
Macedonian
Norwegian
Português
Português
Română
Русский
Español
Svenska
Türkçe
Українська
Choose Currency
£ GBP
$ USD
€ EUR
Generate Password
×
Please enter a number between 8 and 64 for the password length
Password Length
Generated Password
Generate new password
Copy