Bak

Backup all SQL instance databases

I had a situation where I needed to backup hundreds of databases to a USB drive. In this circumstance the GUI was out of the question. After some searching online I found this script: [sourcecode language="sql"]<br />DECLARE @name VARCHAR(50) -- database name<br />DECLARE @path VARCHAR(256) -- path for backup files<br />DECLARE @fileName VARCHAR(256) -- filename for backup<br />DECLARE @fileDate VARCHAR(20) -- used for file name<br /><br />SET @path = 'D:\SQL\Backup\'<br /><br />SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112)<br /><br />DECLARE db_cursor CURSOR FOR<br />SELECT name<br />FROM master.