Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

Backup of Transaction Log shrinks the data file also

$
0
0

When I use the script below to create a backup of the transaction log it appears to 'shrink' the data file as well; is this expected behavior or is there something else going on (am I losing data)?  Here is the tsql for the backup:

/* Backup the Transaction Log, verify when finished, and Perform Checksum before writing to media */
/* NOTE: this backup may need to be done two times before a shrinkfile can be done */
BACKUP LOG [FIS_ADC] TO  DISK = N'C:\Temp\Transaction Log\PostRestoreLogBackup1.trn' WITH NOFORMAT, NOINIT,  NAME = N'FIS_ADC-Transaction Log  Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10, CHECKSUM
GO
declare @backupSetId as int
select @backupSetId = position from msdb..backupset where database_name=N'FIS_ADC' and backup_set_id=(select max(backup_set_id) from msdb..backupset where database_name=N'FIS_ADC' )
if @backupSetId is null begin raiserror(N'Verify failed. Backup information for database ''FIS_ADC'' not found.', 16, 1) end
RESTORE VERIFYONLY FROM  DISK = N'C:\Temp\Transaction Log\PostRestoreLogBackup1.trn' WITH  FILE = @backupSetId,  NOUNLOAD,  NOREWIND
GO

Also:

I use the following commands to find the sizes of my data and log files:

exec [sys].[sp_databases] for the data file size

dbcc sqlperf(logspace) for the log file size and % of log used



Viewing all articles
Browse latest Browse all 12963

Trending Articles