{"id":99,"date":"2012-09-23T22:58:21","date_gmt":"2012-09-24T03:58:21","guid":{"rendered":"https:\/\/danvanfleet.com\/index.php\/automated-softpro-sql-database-backup\/"},"modified":"2013-03-11T16:25:51","modified_gmt":"2013-03-11T21:25:51","slug":"automated-softpro-sql-database-backup","status":"publish","type":"post","link":"https:\/\/danvanfleet.com\/index.php\/automated-softpro-sql-database-backup\/","title":{"rendered":"Automated SoftPro SQL Database Backup"},"content":{"rendered":"<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Backing up the SoftPro SQL database, isn&#8221;t that done automatically was the question of the week.<span style=\"mso-spacerun: yes;\">\u00a0 <\/span>Well yes and no is the answer, if you have a SQL database many times it is not included in your backup.<span style=\"mso-spacerun: yes;\">\u00a0 <\/span>Especially if you&#8221;ve switched to a Cloud based backup.<!--?xml:namespace prefix = o ?--><\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">\u00a0<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">In my humble opinion The entire SoftPro Database should be backed up in this fashion on a regular basis even if your main backup catches it.<span style=\"mso-spacerun: yes;\">\u00a0 <\/span>There is too much valuable data in these files not to be specially protected.<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">\u00a0<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">So what do we do?<\/span><\/p>\n<p><!--more--><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Well there are a few possible answers to that question, here we backup a SQL Express database, version is 2008. There are better tools if you have SQL standard edition.<span style=\"mso-spacerun: yes;\">\u00a0 <\/span>In my travels SoftPro runs fine on Express edition, although I like a few of the tools in Standard edition, so that&#8221;s what my shop runs. <\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">\u00a0<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Open Microsoft SQL Server Management Studio, opening the instance running SoftPro.<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Click on New Query<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Paste the following text in the New Query window. Or Better yet Download the Zip of <a href=\"https:\/\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/SqlBackup.zip\">SqlBackup<\/a> for the 2 files necessary to put this all in place. The Web copy and paste is not being my friend right now.<br \/>\n<\/span><\/p>\n<div id=\"codeSnippetWrapper\" style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 98.88%; font-family: ''Courier New'', courier, monospace; direction: ltr; height: 409px; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: silver 1px solid; padding: 4px;\">\n<div id=\"codeSnippet\" style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">--<span style=\"color: #008000;\">\/\/ Copyright \u00a9 Microsoft Corporation. All Rights Reserved.<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">--<span style=\"color: #008000;\">\/\/ This code released under the terms of the --<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">--<span style=\"color: #008000;\">\/\/ Microsoft Public License (MS-PL, http:\/\/opensource.org\/licenses\/ms-pl.html.)<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">USE<\/span> [master]<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">GO<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">\/****** Object: StoredProcedure [dbo].[sp_BackupDatabases] ******\/ <\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">SET<\/span> ANSI_NULLS <span style=\"color: #0000ff;\">ON<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">GO<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">SET<\/span> QUOTED_IDENTIFIER <span style=\"color: #0000ff;\">ON<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">GO<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- ============================================= <\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- Author: Microsoft <\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- Create date: 2010-02-06<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- Description: Backup Databases for SQLExpress <\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- Parameter1: databaseName <\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- Parameter2: backupType F=full, D=differential, L=log<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- Parameter3: backup file location<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- ============================================= <\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">CREATE<\/span> <span style=\"color: #0000ff;\">PROCEDURE<\/span> [dbo].[sp_BackupDatabases]<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">@databaseName sysname = <span style=\"color: #0000ff;\">null<\/span>,<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">@backupType <span style=\"color: #0000ff;\">CHAR<\/span>(1),<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">@backupLocation nvarchar(200)<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">AS<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">SET<\/span> NOCOUNT <span style=\"color: #0000ff;\">ON<\/span>;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">DECLARE<\/span> @DBs <span style=\"color: #0000ff;\">TABLE<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">(<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">ID <span style=\"color: #0000ff;\">int<\/span> <span style=\"color: #0000ff;\">IDENTITY<\/span> <span style=\"color: #0000ff;\">PRIMARY<\/span> <span style=\"color: #0000ff;\">KEY<\/span>,<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">DBNAME nvarchar(500)<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">)<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- Pick out only databases which are online in case ALL databases are chosen to be backed up<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- If specific database is chosen to be backed up only pick that out from @DBs<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">INSERT <span style=\"color: #0000ff;\">INTO<\/span> @DBs (DBNAME)<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">SELECT<\/span> Name <span style=\"color: #0000ff;\">FROM<\/span> master.sys.databases<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">where<\/span> <span style=\"color: #0000ff;\">state<\/span>=0<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">AND<\/span> name=@DatabaseName<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">OR<\/span> @DatabaseName <span style=\"color: #0000ff;\">IS<\/span> <span style=\"color: #0000ff;\">NULL<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">ORDER<\/span> <span style=\"color: #0000ff;\">BY<\/span> Name<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- Filter out databases which do not need to backed up<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">IF<\/span> @backupType=<span style=\"color: #006080;\">''F''<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">BEGIN<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">DELETE<\/span> @DBs <span style=\"color: #0000ff;\">where<\/span> DBNAME <span style=\"color: #0000ff;\">IN<\/span> (<span style=\"color: #006080;\">''tempdb''<\/span>,<span style=\"color: #006080;\">''Northwind''<\/span>,<span style=\"color: #006080;\">''pubs''<\/span>,<span style=\"color: #006080;\">''AdventureWorks''<\/span>)<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">END<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">ELSE<\/span> <span style=\"color: #0000ff;\">IF<\/span> @backupType=<span style=\"color: #006080;\">''D''<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">BEGIN<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">DELETE<\/span> @DBs <span style=\"color: #0000ff;\">where<\/span> DBNAME <span style=\"color: #0000ff;\">IN<\/span> (<span style=\"color: #006080;\">''tempdb''<\/span>,<span style=\"color: #006080;\">''Northwind''<\/span>,<span style=\"color: #006080;\">''pubs''<\/span>,<span style=\"color: #006080;\">''master''<\/span>,<span style=\"color: #006080;\">''AdventureWorks''<\/span>)<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">END<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">ELSE<\/span> <span style=\"color: #0000ff;\">IF<\/span> @backupType=<span style=\"color: #006080;\">''L''<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">BEGIN<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">DELETE<\/span> @DBs <span style=\"color: #0000ff;\">where<\/span> DBNAME <span style=\"color: #0000ff;\">IN<\/span> (<span style=\"color: #006080;\">''tempdb''<\/span>,<span style=\"color: #006080;\">''Northwind''<\/span>,<span style=\"color: #006080;\">''pubs''<\/span>,<span style=\"color: #006080;\">''master''<\/span>,<span style=\"color: #006080;\">''AdventureWorks''<\/span>)<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">END<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">ELSE<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">BEGIN<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">RETURN<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">END<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- Declare variables<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">DECLARE<\/span> @BackupName <span style=\"color: #0000ff;\">varchar<\/span>(100)<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">DECLARE<\/span> @BackupFile <span style=\"color: #0000ff;\">varchar<\/span>(100)<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">DECLARE<\/span> @DBNAME <span style=\"color: #0000ff;\">varchar<\/span>(300)<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">DECLARE<\/span> @sqlCommand NVARCHAR(1000)<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">DECLARE<\/span> @dateTime NVARCHAR(20)<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">DECLARE<\/span> @Loop <span style=\"color: #0000ff;\">int<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- Loop through the databases one by one<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">SELECT<\/span> @Loop = <span style=\"color: #0000ff;\">min<\/span>(ID) <span style=\"color: #0000ff;\">FROM<\/span> @DBs<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">WHILE<\/span> @Loop <span style=\"color: #0000ff;\">IS<\/span> <span style=\"color: #0000ff;\">NOT<\/span> <span style=\"color: #0000ff;\">NULL<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">BEGIN<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- Database Names have to be in [dbname] format since some have - or _ in their name<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">SET<\/span> @DBNAME = <span style=\"color: #006080;\">''[''<\/span>+(<span style=\"color: #0000ff;\">SELECT<\/span> DBNAME <span style=\"color: #0000ff;\">FROM<\/span> @DBs <span style=\"color: #0000ff;\">WHERE<\/span> ID = @Loop)+<span style=\"color: #006080;\">'']''<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- Set the current date and time n yyyyhhmmss format<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">SET<\/span> @dateTime = REPLACE(<span style=\"color: #0000ff;\">CONVERT<\/span>(<span style=\"color: #0000ff;\">VARCHAR<\/span>, GETDATE(),101),<span style=\"color: #006080;\">''\/''<\/span>,<span style=\"color: #006080;\">''''<\/span>) + <span style=\"color: #006080;\">''_''<\/span> + REPLACE(<span style=\"color: #0000ff;\">CONVERT<\/span>(<span style=\"color: #0000ff;\">VARCHAR<\/span>, GETDATE(),108),<span style=\"color: #006080;\">'':''<\/span>,<span style=\"color: #006080;\">''''<\/span>)<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- Create backup filename in pathfilename.extension format for full,diff and log backups<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">IF<\/span> @backupType = <span style=\"color: #006080;\">''F''<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">SET<\/span> @BackupFile = @backupLocation+REPLACE(REPLACE(@DBNAME, <span style=\"color: #006080;\">''[''<\/span>,<span style=\"color: #006080;\">''''<\/span>),<span style=\"color: #006080;\">'']''<\/span>,<span style=\"color: #006080;\">''''<\/span>)+ <span style=\"color: #006080;\">''_FULL_''<\/span>+ @dateTime+ <span style=\"color: #006080;\">''.BAK''<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">ELSE<\/span> <span style=\"color: #0000ff;\">IF<\/span> @backupType = <span style=\"color: #006080;\">''D''<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">SET<\/span> @BackupFile = @backupLocation+REPLACE(REPLACE(@DBNAME, <span style=\"color: #006080;\">''[''<\/span>,<span style=\"color: #006080;\">''''<\/span>),<span style=\"color: #006080;\">'']''<\/span>,<span style=\"color: #006080;\">''''<\/span>)+ <span style=\"color: #006080;\">''_DIFF_''<\/span>+ @dateTime+ <span style=\"color: #006080;\">''.BAK''<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">ELSE<\/span> <span style=\"color: #0000ff;\">IF<\/span> @backupType = <span style=\"color: #006080;\">''L''<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">SET<\/span> @BackupFile = @backupLocation+REPLACE(REPLACE(@DBNAME, <span style=\"color: #006080;\">''[''<\/span>,<span style=\"color: #006080;\">''''<\/span>),<span style=\"color: #006080;\">'']''<\/span>,<span style=\"color: #006080;\">''''<\/span>)+ <span style=\"color: #006080;\">''_LOG_''<\/span>+ @dateTime+ <span style=\"color: #006080;\">''.TRN''<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- Provide the backup a name for storing in the media<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">IF<\/span> @backupType = <span style=\"color: #006080;\">''F''<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">SET<\/span> @BackupName = REPLACE(REPLACE(@DBNAME,<span style=\"color: #006080;\">''[''<\/span>,<span style=\"color: #006080;\">''''<\/span>),<span style=\"color: #006080;\">'']''<\/span>,<span style=\"color: #006080;\">''''<\/span>) +<span style=\"color: #006080;\">'' full backup for ''<\/span>+ @dateTime<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">IF<\/span> @backupType = <span style=\"color: #006080;\">''D''<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">SET<\/span> @BackupName = REPLACE(REPLACE(@DBNAME,<span style=\"color: #006080;\">''[''<\/span>,<span style=\"color: #006080;\">''''<\/span>),<span style=\"color: #006080;\">'']''<\/span>,<span style=\"color: #006080;\">''''<\/span>) +<span style=\"color: #006080;\">'' differential backup for ''<\/span>+ @dateTime<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">IF<\/span> @backupType = <span style=\"color: #006080;\">''L''<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">SET<\/span> @BackupName = REPLACE(REPLACE(@DBNAME,<span style=\"color: #006080;\">''[''<\/span>,<span style=\"color: #006080;\">''''<\/span>),<span style=\"color: #006080;\">'']''<\/span>,<span style=\"color: #006080;\">''''<\/span>) +<span style=\"color: #006080;\">'' log backup for ''<\/span>+ @dateTime<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- Generate the dynamic SQL command to be executed<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">IF<\/span> @backupType = <span style=\"color: #006080;\">''F''<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">BEGIN<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">SET<\/span> @sqlCommand = <span style=\"color: #006080;\">''BACKUP DATABASE ''<\/span> +@DBNAME+ <span style=\"color: #006080;\">'' TO DISK = ''<\/span><span style=\"color: #006080;\">''''<\/span>+@BackupFile+ <span style=\"color: #006080;\">''''<\/span><span style=\"color: #006080;\">'' WITH INIT, NAME= ''<\/span><span style=\"color: #006080;\">''''<\/span> +@BackupName+<span style=\"color: #006080;\">''''<\/span><span style=\"color: #006080;\">'', NOSKIP, NOFORMAT''<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">END<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">IF<\/span> @backupType = <span style=\"color: #006080;\">''D''<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">BEGIN<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">SET<\/span> @sqlCommand = <span style=\"color: #006080;\">''BACKUP DATABASE ''<\/span> +@DBNAME+ <span style=\"color: #006080;\">'' TO DISK = ''<\/span><span style=\"color: #006080;\">''''<\/span>+@BackupFile+ <span style=\"color: #006080;\">''''<\/span><span style=\"color: #006080;\">'' WITH DIFFERENTIAL, INIT, NAME= ''<\/span><span style=\"color: #006080;\">''''<\/span> +@BackupName+<span style=\"color: #006080;\">''''<\/span><span style=\"color: #006080;\">'', NOSKIP, NOFORMAT''<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">END<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">IF<\/span> @backupType = <span style=\"color: #006080;\">''L''<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">BEGIN<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">SET<\/span> @sqlCommand = <span style=\"color: #006080;\">''BACKUP LOG ''<\/span> +@DBNAME+ <span style=\"color: #006080;\">'' TO DISK = ''<\/span><span style=\"color: #006080;\">''''<\/span>+@BackupFile+ <span style=\"color: #006080;\">''''<\/span><span style=\"color: #006080;\">'' WITH INIT, NAME= ''<\/span><span style=\"color: #006080;\">''''<\/span> +@BackupName+<span style=\"color: #006080;\">''''<\/span><span style=\"color: #006080;\">'', NOSKIP, NOFORMAT''<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">END<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- Execute the generated SQL command<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">EXEC<\/span>(@sqlCommand)<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #008000;\">-- Goto the next database<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">SELECT<\/span> @Loop = <span style=\"color: #0000ff;\">min<\/span>(ID) <span style=\"color: #0000ff;\">FROM<\/span> @DBs <span style=\"color: #0000ff;\">where<\/span> ID&gt;@Loop<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">END<\/pre>\n<p><!--CRLF--><\/p>\n<\/div>\n<\/div>\n<p style=\"margin: 0in 0in 0pt;\">\n<style type=\"text\/css\"><!--\n.csharpcode, .csharpcode pre\n{\n\tfont-size: small;\n\tcolor: black;\n\tfont-family: consolas, \"Courier New\", courier, monospace;\n\tbackground-color: #ffffff;\n\t\/*white-space: pre;*\/\n}\n.csharpcode pre { margin: 0em; }\n.csharpcode .rem { color: #008000; }\n.csharpcode .kwrd { color: #0000ff; }\n.csharpcode .str { color: #006080; }\n.csharpcode .op { color: #0000c0; }\n.csharpcode .preproc { color: #cc6633; }\n.csharpcode .asp { background-color: #ffff00; }\n.csharpcode .html { color: #800000; }\n.csharpcode .attr { color: #ff0000; }\n.csharpcode .alt \n{\n\tbackground-color: #f4f4f4;\n\twidth: 100%;\n\tmargin: 0em;\n}\n.csharpcode .lnum { color: #606060; }\n--><\/style>\n<p style=\"margin: 0in 0in 0pt;\">\n<style type=\"text\/css\"><!--\n.csharpcode, .csharpcode pre\n{\n\tfont-size: small;\n\tcolor: black;\n\tfont-family: consolas, \"Courier New\", courier, monospace;\n\tbackground-color: #ffffff;\n\t\/*white-space: pre;*\/\n}\n.csharpcode pre { margin: 0em; }\n.csharpcode .rem { color: #008000; }\n.csharpcode .kwrd { color: #0000ff; }\n.csharpcode .str { color: #006080; }\n.csharpcode .op { color: #0000c0; }\n.csharpcode .preproc { color: #cc6633; }\n.csharpcode .asp { background-color: #ffff00; }\n.csharpcode .html { color: #800000; }\n.csharpcode .attr { color: #ff0000; }\n.csharpcode .alt \n{\n\tbackground-color: #f4f4f4;\n\twidth: 100%;\n\tmargin: 0em;\n}\n.csharpcode .lnum { color: #606060; }\n--><\/style>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Then Click the Execute button <\/span><span style=\"mso-no-proof: yes;\"><a href=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image002.jpg\"><img data-recalc-dims=\"1\" decoding=\"async\" style=\"margin: 0px; display: inline; border-width: 0px;\" title=\"clip_image002\" alt=\"clip_image002\" src=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image002_thumb.jpg?resize=50%2C20\" width=\"50\" height=\"20\" border=\"0\" \/><\/a> (If you receive errors, search the text for &#8221;&#8221; (double single quote) and replace with &#8221; (single quote) there is something in WordPress that is causing the single quote to be doubled in the post.)<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">In short order &#8220;Command(s) completed successfully should display<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"mso-no-proof: yes;\"><a href=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image004.jpg\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" style=\"display: inline; margin-left: 0px; margin-right: 0px; border-width: 0px;\" title=\"clip_image004\" alt=\"clip_image004\" src=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image004_thumb.jpg?resize=496%2C469\" width=\"496\" height=\"469\" border=\"0\" \/><\/a><\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"mso-no-proof: yes;\"><a href=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image006.jpg\"><img data-recalc-dims=\"1\" decoding=\"async\" style=\"margin: 0px 10px 0px 0px; display: inline; border-width: 0px;\" title=\"clip_image006\" alt=\"clip_image006\" src=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image006_thumb.jpg?resize=244%2C43\" width=\"244\" height=\"43\" align=\"left\" border=\"0\" \/><\/a><\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">If the command did not complete <\/span><span style=\"mso-no-proof: yes;\"><br \/>\n<a href=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image008.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" style=\"margin: 0px 10px 0px 0px; display: inline; border-width: 0px;\" title=\"clip_image008\" alt=\"clip_image008\" src=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image008_thumb.jpg?resize=244%2C186\" width=\"244\" height=\"186\" align=\"left\" border=\"0\" \/><\/a><\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">successfully, be sure to Refresh object Explorer by clicking in it and pressing F5<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">In that case, if the Stored <\/span><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Procedure highlighted above (dbo.sp_BackupDatabases) exists, delete it (press the delete button) and try again.<span style=\"mso-spacerun: yes;\">\u00a0 <\/span>Use the error messages to locate the problem. We know of no issues with this script, Microsoft wrote it, so it should be good.<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">The script created a tool we can use to easily backup the database using a batch file or other scripting language file, we will make a simple batch file.\u00a0 The delete by date section of the batch file will only run on newer operating systems that include the forfiles command. (newer than vista or server wise windows2008)<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">\u00a0<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Before we start let&#8221;s gather some information.<span style=\"mso-spacerun: yes;\">\u00a0 <\/span>We are going to need to know three things;<\/span><\/p>\n<ol>\n<li>\n<div style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">The SQL Server Name and Instance name if any<\/span><\/div>\n<\/li>\n<li>\n<div style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">The Location we want to backup databases to<\/span><\/div>\n<\/li>\n<li>\n<div style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">How many days of the backup do you want to save on the hard disk<\/span><\/div>\n<\/li>\n<\/ol>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">So open Notepad, I use <a href=\"http:\/\/notepad-plus-plus.org\/\">NotePad++<\/a> which is way better than Notepad. Copy the following batch file into Notepad.<\/span><\/p>\n<div id=\"codeSnippetWrapper\" style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: ''Courier New'', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: silver 1px solid; padding: 4px;\">\n<div id=\"codeSnippet\" style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">@Echo Off<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">: Change the SQLServer <span style=\"color: #0000ff;\">to<\/span> your SQL Server <span style=\"color: #0000ff;\">and<\/span> Instance<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">Set<\/span> SQLServer=Server09SoftPro<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">: Change BackupTo= <span style=\"color: #0000ff;\">to<\/span> the location you wish <span style=\"color: #0000ff;\">to<\/span> save your backups.  Don<span style=\"color: #008000;\">''t forget the trailing backslash.<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">Set<\/span> BackupTo=F:_backupsSLTSSoftProDataBaseBackup<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">: How many days of backups <span style=\"color: #0000ff;\">do<\/span> you want <span style=\"color: #0000ff;\">to<\/span> keep <span style=\"color: #0000ff;\">on<\/span> the live system. We\u2019re <span style=\"color: #0000ff;\">not<\/span> dealing <span style=\"color: #0000ff;\">with<\/span> weekends here, straight days.<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">Set<\/span> DaysToSave=10<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">: Don<span style=\"color: #008000;\">''t edit below here if you don''t get what\u2019s going on.<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">Echo <span style=\"color: #0000ff;\">on<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">forfiles \/p %BackupTo% -M *.bak \/D -%DaysToSave% \/C <span style=\"color: #006080;\">\"cmd \/c del @path\"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">@Echo Off<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">: Disable the above line <span style=\"color: #0000ff;\">and<\/span> enable the below line <span style=\"color: #0000ff;\">on<\/span> old OS <span style=\"color: #0000ff;\">to<\/span> keep one day<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">: Del %BackupTo%*.bak<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">sqlcmd -S %SQLServer% -E -Q <span style=\"color: #006080;\">\"EXEC sp_BackupDatabases @backupLocation=''%BackupTo%'', @backupType=''F''\"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">: Cleanup<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">Set<\/span> SQLServer=<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">Set<\/span> BackupTo=<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">Set<\/span> DaysToSave=<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: ''Courier New'', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">:<span style=\"color: #0000ff;\">End<\/span> of SoftProSQLBackup.Bat<\/pre>\n<p><!--CRLF--><\/p>\n<\/div>\n<\/div>\n<p><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Change the lines below the 2 &#8220;:Change&#8221; comments to be your SQL server, where you want the backup to go, and how many days to keep.<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Save the file as &#8220;SoftProSQLBackup.bat&#8221;, <span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\"><a href=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/image.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" style=\"margin: 5px 0px 0px 10px; display: inline; border-width: 0px;\" title=\"image\" alt=\"image\" src=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/image_thumb.png?resize=349%2C69\" width=\"349\" height=\"69\" align=\"right\" border=\"0\" \/><\/a><\/span>normally you should not include the double quotes in this case if you are using Notepad, be sure to use them, or Notepad will try to help you and save the file incorrectly as a text file.<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Where to save it is your choice, I saved it to the save folder the backups go to.<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Now it&#8221;s time to test it.<span style=\"mso-spacerun: yes;\">\u00a0 <\/span>Double click on the newly created &#8220;SoftProSQLBackup.bat&#8221; file using Windows Explorer.<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"mso-no-proof: yes;\"><a href=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image010.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"clip_image010\" alt=\"clip_image010\" src=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image010_thumb.jpg?resize=382%2C154\" width=\"382\" height=\"154\" border=\"0\" \/><\/a><\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">\u00a0<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"mso-no-proof: yes;\"><a href=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image012.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" style=\"margin: 0px 0px 0px 10px; display: inline; border-width: 0px;\" title=\"clip_image012\" alt=\"clip_image012\" src=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image012_thumb.jpg?resize=244%2C77\" width=\"244\" height=\"77\" align=\"right\" border=\"0\" \/><\/a><\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">A Command line window will pop up and probably n<\/span><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">ot stay around very long<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\" align=\"right\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Ignore the first line, there are no *.bak files to delete just yet.<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">\u00a0<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"mso-no-proof: yes;\"><a href=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image014.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" style=\"margin: 0px 0px 0px 10px; display: inline; border-width: 0px;\" title=\"clip_image014\" alt=\"clip_image014\" src=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image014_thumb.jpg?resize=244%2C118\" width=\"244\" height=\"118\" align=\"right\" border=\"0\" \/><\/a><\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Windows Explorer will update showing the newly created files<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">\u00a0<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">The next time you run it, the file names will change as will the Date Modified.<span style=\"mso-spacerun: yes;\">\u00a0 <\/span>Make sure your Cloud backup, or other backup will include this folder and you are good to go.<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">\u00a0<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Well maybe not quite good to go.<span style=\"mso-spacerun: yes;\">\u00a0 <\/span>Next we need to Schedule this batch file to run via the Task Scheduler.<span style=\"mso-spacerun: yes;\">\u00a0 <\/span>I&#8221;m not going to go into much depth doing this, as the Task Scheduler varies depending on the Operating System you are using.<span style=\"mso-spacerun: yes;\">\u00a0 <\/span>I write this using Windows Server 2008 R2.<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">\u00a0<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"mso-no-proof: yes;\"><a href=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image016.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" style=\"margin: 0px 0px 0px 10px; display: inline; border-width: 0px;\" title=\"clip_image016\" alt=\"clip_image016\" src=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image016_thumb.jpg?resize=244%2C35\" width=\"244\" height=\"35\" align=\"right\" border=\"0\" \/><\/a><\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Start Task Scheduler the easy way Type it in the search box<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">You can also find it in control Panel, either directly or under Administrative Tools, depending on your OS.<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"mso-no-proof: yes;\"><a href=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image018.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" style=\"margin: 0px 0px 0px 10px; display: inline; border-width: 0px;\" title=\"clip_image018\" alt=\"clip_image018\" src=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image018_thumb.jpg?resize=244%2C188\" width=\"244\" height=\"188\" align=\"right\" border=\"0\" \/><\/a><\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Click on Create Basic Task on the Actions Panel.<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"mso-no-proof: yes;\"><a href=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image020.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"clip_image020\" alt=\"clip_image020\" src=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image020_thumb.jpg?resize=244%2C169\" width=\"244\" height=\"169\" border=\"0\" \/><\/a><\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Give it a name and a Description if you wish.<span style=\"mso-spacerun: yes;\">\u00a0 <\/span>The Name is necessary.<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Click Next<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"mso-no-proof: yes;\"><a href=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image022.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" style=\"margin: 0px 0px 0px 10px; display: inline; border-width: 0px;\" title=\"clip_image022\" alt=\"clip_image022\" src=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image022_thumb.jpg?resize=244%2C216\" width=\"244\" height=\"216\" align=\"right\" border=\"0\" \/><\/a><\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Daily is the minimum recommended run time.<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Click Next<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"mso-no-proof: yes;\"><a href=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image024.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" style=\"display: inline; margin-left: 0px; margin-right: 0px; border-width: 0px;\" title=\"clip_image024\" alt=\"clip_image024\" src=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image024_thumb.jpg?resize=244%2C58\" width=\"244\" height=\"58\" align=\"right\" border=\"0\" \/><\/a><\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Give it a time and date to run, preferably before the main backup starts.<span style=\"mso-spacerun: yes;\">\u00a0 <\/span>Let it run every day, and don&#8221;t worry about time zones.<span style=\"mso-spacerun: yes;\">\u00a0 <\/span>If you need to worry about them, you&#8221;re probably not reading this.<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Click Next<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"mso-no-proof: yes;\"><a href=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image026.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" style=\"display: inline; margin-left: 0px; margin-right: 0px; border-width: 0px;\" title=\"clip_image026\" alt=\"clip_image026\" src=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image026_thumb.jpg?resize=244%2C116\" width=\"244\" height=\"116\" align=\"left\" border=\"0\" \/><\/a><\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">We want to Start a Program, Click Next<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">\u00a0<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"mso-no-proof: yes;\"><a href=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image028.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" style=\"display: inline; margin-left: 0px; margin-right: 0px; border-width: 0px;\" title=\"clip_image028\" alt=\"clip_image028\" src=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image028_thumb.jpg?resize=244%2C78\" width=\"244\" height=\"78\" align=\"right\" border=\"0\" \/><\/a><\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Click Browse and navigate to the batch file we created<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\">\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Click Next<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"mso-no-proof: yes;\"><a href=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image030.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" style=\"display: inline; margin-left: 0px; margin-right: 0px; border-width: 0px;\" title=\"clip_image030\" alt=\"clip_image030\" src=\"https:\/\/i0.wp.com\/danvanfleet.com\/wp-content\/uploads\/2012\/09\/clip_image030_thumb.jpg?resize=244%2C175\" width=\"244\" height=\"175\" align=\"right\" border=\"0\" \/><\/a><\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Click Finish<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">\u00a0<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">Your automated backup of the ProForm SQL database is complete.<span style=\"mso-spacerun: yes;\">\u00a0 <\/span>This method backs up all databases if you want to limit the databases backed up by this script visit this <a href=\"http:\/\/support.microsoft.com\/kb\/2019698\">Microsoft Knowledge base article<\/a>.<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">\u00a0<\/span><\/p>\n<p style=\"margin: 0in 0in 0pt;\"><span style=\"font-family: ''Calibri'',''sans-serif''; font-size: 11pt;\">The method I used to select files by date, opens a new command shell for every file, real fast.\u00a0 If your SQL server contains thousands of databases, you\u2019ll want to use a different for loop.\u00a0 opening 10 or even 40 command prompts real quick isn\u2019t a big deal. Five hundred of them, probably not a good idea.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Backing up the SoftPro SQL database, isn&#8221;t that done automatically was the question of the week.\u00a0 Well yes and no is the answer, if you have a SQL database many times it is not included in your backup.\u00a0 Especially if you&#8221;ve switched to a Cloud based backup. \u00a0 In my humble opinion The entire SoftPro [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[23,5],"tags":[14,8,13],"class_list":["post-99","post","type-post","status-publish","format-standard","hentry","category-softpro-2","category-using-computers","tag-os","tag-softpro","tag-sql","entry"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4wyVb-1B","jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/danvanfleet.com\/index.php\/wp-json\/wp\/v2\/posts\/99","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/danvanfleet.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/danvanfleet.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/danvanfleet.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/danvanfleet.com\/index.php\/wp-json\/wp\/v2\/comments?post=99"}],"version-history":[{"count":4,"href":"https:\/\/danvanfleet.com\/index.php\/wp-json\/wp\/v2\/posts\/99\/revisions"}],"predecessor-version":[{"id":515,"href":"https:\/\/danvanfleet.com\/index.php\/wp-json\/wp\/v2\/posts\/99\/revisions\/515"}],"wp:attachment":[{"href":"https:\/\/danvanfleet.com\/index.php\/wp-json\/wp\/v2\/media?parent=99"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/danvanfleet.com\/index.php\/wp-json\/wp\/v2\/categories?post=99"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/danvanfleet.com\/index.php\/wp-json\/wp\/v2\/tags?post=99"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}