根據前一篇關於自動備份的文章,對應的自動還原方案
create procedure [dbo].[sp_RestoreDatabase]
@SourceDirBackupFiles NVARCHAR(200)
as
declare @DatabaseName sysname
--Table to hold the result from RESTORE HEADERONLY. Needed to get the database name out from
CREATE TABLE #bdev(
BackupName NVARCHAR(128)
,BackupDescription NVARCHAR(255)
,BackupType smallint
,ExpirationDate datetime
,Compressed tinyint
,Position smallint
,DeviceType tinyint
,UserName NVARCHAR(128)
,ServerName NVARCHAR(128)
,DatabaseName NVARCHAR(128)
,DatabaseVersion INT
,DatabaseCreationDate datetime
,BackupSize numeric(20,0)
,FirstLSN numeric(25,0)
,LastLSN numeric(25,0)
,CheckpointLSN numeric(25,0)
,DatabaseBackupLSN numeric(25,0)
,BackupStartDate datetime
,BackupFinishDate datetime
,SortOrder smallint
,CodePage smallint
,UnicodeLocaleId INT
,UnicodeComparisonStyle INT
,CompatibilityLevel tinyint
,SoftwareVendorId INT
,SoftwareVersionMajor INT
,SoftwareVersionMinor INT
,SoftwareVersionBuild INT
,MachineName NVARCHAR(128)
,Flags INT
,BindingID uniqueidentifier
,RecoveryForkID uniqueidentifier
,Collation NVARCHAR(128)
,FamilyGUID uniqueidentifier
,HasBulkLoggedData INT
,IsSnapshot INT
,IsReadOnly INT
,IsSingleUser INT
,HasBackupChecksums INT
,IsDamaged INT
,BegibsLogChain INT
,HasIncompleteMetaData INT
,IsForceOffline INT
,IsCopyOnly INT
,FirstRecoveryForkID uniqueidentifier
,ForkPointLSN numeric(25,0)
,RecoveryModel NVARCHAR(128)
,DifferentialBaseLSN numeric(25,0)
,DifferentialBaseGUID uniqueidentifier
,BackupTypeDescription NVARCHAR(128)
,BackupSetGUID uniqueidentifier
)
TRUNCATE TABLE #bdev
INSERT #bdev
EXEC('RESTORE HEADERONLY from DISK = ''' + @SourceDirBackupFiles + '''')
--select * from #bdev
declare @position int
declare @BackupType int
declare @last_log_position int
select @last_log_position=ma
1.Oracle删除重复记录.
删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录.
delete from people
where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)
and rowid not i ......
也是SQL Server 2005带来的新特性,部分备份(partial backup)自动创建数据库中主文件组和所有激活读写功能的文件组的备份。如果备份存在只读文件组的数据库,部分备份将只对主文件组进行备份。这个选项对于那些存在只读文件组的超大型数据库是理想的,它不需要像那些可写的文件组备份得那么频繁。
除了需要指定READ_WRIT ......