Monday 4 May 2009

Create a script to backup user databases

This creates a script that will backup all user databases on the server.

USE MASTER
SELECT 'USE [' + NAME + ']'+ 'BACKUP DATABASE [' + NAME + ']'
+ 'TO DISK = ''Z:\oneoffbackups\' + NAME + '.bak'' WITH INIT'
FROM sysdatabases
WHERE dbid > 4

No comments:

Post a Comment

Note: only a member of this blog may post a comment.