Generate Full Backup Scripts for all User Database in SQL Server

Here is script that can be used to generate Full Backup Scripts for all the user databases in SQL Server.

Declare @BackupPath VARCHAR(100)
SEt @BackupPath='c:\Backup\'
Select 'BACKUP DATABASE ['+name+'] TO  DISK = N'''+@BackupPath+''+name+'.bak''
WITH NOFORMAT, NOINIT,  NAME = N'''+name+'-Full Database Backup'', SKIP, NOREWIND, NOUNLOAD, COMPRESSION,  STATS = 10'

 from sys.databases
where database_id>4

No comments:

Post a Comment