Sunday, March 11, 2012

BACKUP DATABASE

DECLARE @.Name varchar(50)
DECLARE @.Disk varchar(255)
SET @.Name='Databasename'
SET @.Disk = 'Drive:\path\' + @.Name +'.bak'
BACKUP DATABASE @.Name to DISK = @.Disk
BACKUP LOG @.Name
WITH
NO_LOG
DBCC SHRINKDATABASE (@.Name, TRUNCATEONLY)
I plan to run this sort of logic on a wly schedule. Does truncating the
log pose any problems? If so, how do I manage the log size.Wes
http://www.karaszi.com/sqlserver/info_dont_shrink.asp
"Wes" <Wes@.discussions.microsoft.com> wrote in message
news:374F9E8B-2BF5-46E1-BDD5-6AFA580F8849@.microsoft.com...
> DECLARE @.Name varchar(50)
> DECLARE @.Disk varchar(255)
> SET @.Name='Databasename'
> SET @.Disk = 'Drive:\path' + @.Name +'.bak'
> BACKUP DATABASE @.Name to DISK = @.Disk
> BACKUP LOG @.Name
> WITH
> NO_LOG
> DBCC SHRINKDATABASE (@.Name, TRUNCATEONLY)
> I plan to run this sort of logic on a wly schedule. Does truncating
> the
> log pose any problems? If so, how do I manage the log size.
>|||In addition to the link Uri posted you almost never want to do a truncate on
the log as it makes the log useless for a restore. Either backup the log on
a regular basis or set the recovery mode to simple.
Andrew J. Kelly SQL MVP
"Wes" <Wes@.discussions.microsoft.com> wrote in message
news:374F9E8B-2BF5-46E1-BDD5-6AFA580F8849@.microsoft.com...
> DECLARE @.Name varchar(50)
> DECLARE @.Disk varchar(255)
> SET @.Name='Databasename'
> SET @.Disk = 'Drive:\path' + @.Name +'.bak'
> BACKUP DATABASE @.Name to DISK = @.Disk
> BACKUP LOG @.Name
> WITH
> NO_LOG
> DBCC SHRINKDATABASE (@.Name, TRUNCATEONLY)
> I plan to run this sort of logic on a wly schedule. Does truncating
> the
> log pose any problems? If so, how do I manage the log size.
>

No comments:

Post a Comment