tips & tricks


Calendario
dicembre 2024
lmmgvsd
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

BACKUP DATABASE

BACKUP AND RESTORE sintax



BACKUP DATABASE [dbname] TO  DISK = N'D:\Database\Backup\20180102_dbname.bak' WITH  COPY_ONLY, NOFORMAT, INIT,  NAME = N'dbname-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10

GO

declare @backupSetId as int

select @backupSetId = position from msdb..backupset where database_name=N'dbname' and backup_set_id=(select max(backup_set_id) from msdb..backupset where database_name=N'dbname' )

if @backupSetId is null begin raiserror(N'Verify failed. Backup information for database ''dbname'' not found.', 16, 1) end

RESTORE VERIFYONLY FROM  DISK = N'D:\Database\Backup\20180102_dbname.bak' WITH  FILE = @backupSetId,  NOUNLOAD,  NOREWIND
GO



RESTORE DATABASE [dbname] FROM  DISK = N'D:\MSSQLSERVER\20180102\20180102_dbname.bak' WITH  FILE = 1,  

MOVE N'dbname' TO N'D:\Database\DATA\dbname.mdf',  

MOVE N'dbname_log' TO N'D:\Database\DATA\dbname.LDF',  NOUNLOAD,  REPLACE,  STATS = 10

GO

Categoria: SQLServer
martedì, 09 gen 2018 Ore. 11.19
Archivio Posts
Anno 2020

Anno 2018

Anno 2015

Anno 2013

Anno 2011

Anno 2010

Anno 2009

Anno 2008
Statistiche
  • Views Home Page: 14.873
  • Views Posts: 57.949
  • Views Gallerie: 2.837
  • n° Posts: 117
  • n° Commenti: 1
Copyright © 2002-2007 - Blogs 2.0
dotNetHell.it | Home Page Blogs
ASP.NET 2.0 Windows 2003