<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:series="http://unfoldingneurons.com/"
		>
<channel>
	<title>Comments on: Automate Backup Database on SQL Server, Part I: Create VB Script</title>
	<atom:link href="http://www.linglom.com/2009/01/29/automate-backup-database-on-sql-server-part-i-create-vb-script/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.linglom.com/2009/01/29/automate-backup-database-on-sql-server-part-i-create-vb-script/</link>
	<description>Just another IT weblog</description>
	<lastBuildDate>Thu, 09 Sep 2010 00:28:56 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Alext82</title>
		<link>http://www.linglom.com/2009/01/29/automate-backup-database-on-sql-server-part-i-create-vb-script/comment-page-1/#comment-6616</link>
		<dc:creator>Alext82</dc:creator>
		<pubDate>Sat, 10 Jul 2010 17:51:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.linglom.com/?p=597#comment-6616</guid>
		<description>Hi all,

Personally, i prefer a SQL script that backups all my DBs (or a selection), If wanted, you can use sqlcmd.exe to execute it automatically.

Note the first sql select; the WHERE clause you can use to filter what DBs you want to backup (or not backup).

[CODE]
DECLARE @DBName varchar(100)
DECLARE @BUPath varchar(100)
DECLARE @BUName varchar(100)


	DECLARE MyCursor CURSOR 
	FORWARD_ONLY
	FOR
	SELECT Name FROM SYS.Databases WHERE Name NOT IN(&#039;DB1&#039;,&#039;DB2&#039;)


	OPEN MyCursor

	FETCH NEXT FROM MyCursor INTO @DBName
				
	WHILE @@FETCH_STATUS = 0 
	BEGIN	
	 --Backup NOW!
	SELECT @BUPath = &#039;E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\&#039; + @DBName + &#039;.bak&#039;
	SELECT @BUName = @DBName + &#039;-Full Before Upgrade&#039;
	BACKUP DATABASE @DBName TO  DISK = @BUPath WITH NOFORMAT, NOINIT,  NAME = @BUName, SKIP, NOREWIND, NOUNLOAD,  STATS = 10
	--GO

	FETCH NEXT FROM MyCursor INTO @DBName
	END 
	CLOSE MyCursor
	DEALLOCATE MyCursor




[/CODE]</description>
		<content:encoded><![CDATA[<p>Hi all,</p>
<p>Personally, i prefer a SQL script that backups all my DBs (or a selection), If wanted, you can use sqlcmd.exe to execute it automatically.</p>
<p>Note the first sql select; the WHERE clause you can use to filter what DBs you want to backup (or not backup).</p>
<p>[CODE]<br />
DECLARE @DBName varchar(100)<br />
DECLARE @BUPath varchar(100)<br />
DECLARE @BUName varchar(100)</p>
<p>	DECLARE MyCursor CURSOR<br />
	FORWARD_ONLY<br />
	FOR<br />
	SELECT Name FROM SYS.Databases WHERE Name NOT IN(&#8216;DB1&#8242;,&#8217;DB2&#8242;)</p>
<p>	OPEN MyCursor</p>
<p>	FETCH NEXT FROM MyCursor INTO @DBName</p>
<p>	WHILE @@FETCH_STATUS = 0<br />
	BEGIN<br />
	 &#8211;Backup NOW!<br />
	SELECT @BUPath = &#8216;E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\&#8217; + @DBName + &#8216;.bak&#8217;<br />
	SELECT @BUName = @DBName + &#8216;-Full Before Upgrade&#8217;<br />
	BACKUP DATABASE @DBName TO  DISK = @BUPath WITH NOFORMAT, NOINIT,  NAME = @BUName, SKIP, NOREWIND, NOUNLOAD,  STATS = 10<br />
	&#8211;GO</p>
<p>	FETCH NEXT FROM MyCursor INTO @DBName<br />
	END<br />
	CLOSE MyCursor<br />
	DEALLOCATE MyCursor</p>
<p>[/CODE]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: linglom</title>
		<link>http://www.linglom.com/2009/01/29/automate-backup-database-on-sql-server-part-i-create-vb-script/comment-page-1/#comment-6070</link>
		<dc:creator>linglom</dc:creator>
		<pubDate>Tue, 23 Feb 2010 03:37:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.linglom.com/?p=597#comment-6070</guid>
		<description>Hi, Peter
You can backup to a remote folder by map drive or use UNC path (\\remote-server\share). But don&#039;t forget to give appropriate permission to the remote folder.

For the second question, INSTANCE01 is an instance name of the SQL Server on the example. It is similar to SQL-Server\SQLEXPRESS where SQLEXPRESS is an instance name of the SQL Server.</description>
		<content:encoded><![CDATA[<p>Hi, Peter<br />
You can backup to a remote folder by map drive or use UNC path (\\remote-server\share). But don&#8217;t forget to give appropriate permission to the remote folder.</p>
<p>For the second question, INSTANCE01 is an instance name of the SQL Server on the example. It is similar to SQL-Server\SQLEXPRESS where SQLEXPRESS is an instance name of the SQL Server.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://www.linglom.com/2009/01/29/automate-backup-database-on-sql-server-part-i-create-vb-script/comment-page-1/#comment-6049</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Fri, 19 Feb 2010 21:37:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.linglom.com/?p=597#comment-6049</guid>
		<description>I&#039;m using a remote server with a dedicated path to the database. How do I handle that... 

Second: What&#039;s INSTANCE01? Is that required for SQL Server 2005/2008 and can I just put the IP address.

Thanks,

Peter</description>
		<content:encoded><![CDATA[<p>I&#8217;m using a remote server with a dedicated path to the database. How do I handle that&#8230; </p>
<p>Second: What&#8217;s INSTANCE01? Is that required for SQL Server 2005/2008 and can I just put the IP address.</p>
<p>Thanks,</p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jamil Shah</title>
		<link>http://www.linglom.com/2009/01/29/automate-backup-database-on-sql-server-part-i-create-vb-script/comment-page-1/#comment-5936</link>
		<dc:creator>Jamil Shah</dc:creator>
		<pubDate>Fri, 12 Feb 2010 11:48:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.linglom.com/?p=597#comment-5936</guid>
		<description>thank a lot for such a good informative materials.  

Best regards
jamil shah afridi</description>
		<content:encoded><![CDATA[<p>thank a lot for such a good informative materials.  </p>
<p>Best regards<br />
jamil shah afridi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SU</title>
		<link>http://www.linglom.com/2009/01/29/automate-backup-database-on-sql-server-part-i-create-vb-script/comment-page-1/#comment-5051</link>
		<dc:creator>SU</dc:creator>
		<pubDate>Wed, 13 Jan 2010 11:20:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.linglom.com/?p=597#comment-5051</guid>
		<description>GR8...it wors awsome...once i install the BC for SQL 2005 !

thanks a lot once again....

the script now works like a gem on SQL Server 2008

thanks a lot man...</description>
		<content:encoded><![CDATA[<p>GR8&#8230;it wors awsome&#8230;once i install the BC for SQL 2005 !</p>
<p>thanks a lot once again&#8230;.</p>
<p>the script now works like a gem on SQL Server 2008</p>
<p>thanks a lot man&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: linglom</title>
		<link>http://www.linglom.com/2009/01/29/automate-backup-database-on-sql-server-part-i-create-vb-script/comment-page-1/#comment-5047</link>
		<dc:creator>linglom</dc:creator>
		<pubDate>Wed, 13 Jan 2010 04:24:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.linglom.com/?p=597#comment-5047</guid>
		<description>Hi, SU
I&#039;ve just noticed that you are using SQL Server 2008. There is an issue about it. See &lt;a href=&quot;http://www.linglom.com/2010/01/13/solved-activex-component-cant-create-object-sqldmo-sqlserver-on-sql-server-2008/&quot; rel=&quot;nofollow&quot;&gt;[Solved] ActiveX component can&#039;t create object: &#039;SQLDMO.SQLServer&#039; on SQL Server 2008&lt;/a&gt; for a solution.</description>
		<content:encoded><![CDATA[<p>Hi, SU<br />
I&#8217;ve just noticed that you are using SQL Server 2008. There is an issue about it. See <a href="http://www.linglom.com/2010/01/13/solved-activex-component-cant-create-object-sqldmo-sqlserver-on-sql-server-2008/" rel="nofollow">[Solved] ActiveX component can&#8217;t create object: &#8216;SQLDMO.SQLServer&#8217; on SQL Server 2008</a> for a solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SU</title>
		<link>http://www.linglom.com/2009/01/29/automate-backup-database-on-sql-server-part-i-create-vb-script/comment-page-1/#comment-5042</link>
		<dc:creator>SU</dc:creator>
		<pubDate>Tue, 12 Jan 2010 08:50:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.linglom.com/?p=597#comment-5042</guid>
		<description>im running the script locally only...

also as suggested by you, if i comment &quot;on error resume next&quot;, i get the following error Activex component can&#039;t create object: &#039;SQLDMO.SQLServer&#039;wihtout commenting it, it just says backup complete...and i du not see anything in the backup folder.

also i created a new blank Db and then tried running this script. still the same thing happens...

please suggest.....</description>
		<content:encoded><![CDATA[<p>im running the script locally only&#8230;</p>
<p>also as suggested by you, if i comment &#8220;on error resume next&#8221;, i get the following error Activex component can&#8217;t create object: &#8216;SQLDMO.SQLServer&#8217;wihtout commenting it, it just says backup complete&#8230;and i du not see anything in the backup folder.</p>
<p>also i created a new blank Db and then tried running this script. still the same thing happens&#8230;</p>
<p>please suggest&#8230;..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: linglom</title>
		<link>http://www.linglom.com/2009/01/29/automate-backup-database-on-sql-server-part-i-create-vb-script/comment-page-1/#comment-5039</link>
		<dc:creator>linglom</dc:creator>
		<pubDate>Tue, 12 Jan 2010 02:38:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.linglom.com/?p=597#comment-5039</guid>
		<description>Hi, SU
You can try remove this line in the code:
&lt;pre lang=&#039;vb&#039;&gt;On Error Resume Next&lt;/pre&gt;

Then, try to execute the script manually as &#039;Ya S&#039; told to see if there is any error message.</description>
		<content:encoded><![CDATA[<p>Hi, SU<br />
You can try remove this line in the code:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">On</span> <span style="color: #000080;">Error</span> <span style="color: #000080;">Resume</span> <span style="color: #000080;">Next</span></pre></div></div>

<p>Then, try to execute the script manually as &#8216;Ya S&#8217; told to see if there is any error message.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ya S</title>
		<link>http://www.linglom.com/2009/01/29/automate-backup-database-on-sql-server-part-i-create-vb-script/comment-page-1/#comment-5037</link>
		<dc:creator>Ya S</dc:creator>
		<pubDate>Mon, 11 Jan 2010 16:52:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.linglom.com/?p=597#comment-5037</guid>
		<description>Hi SU,

You can try and execute the script locally on the machine - this way you may see the error. One of the possibilities is that the DB is in use and cannot be detached - make sure SQL Management Studio is not logged to the DB.</description>
		<content:encoded><![CDATA[<p>Hi SU,</p>
<p>You can try and execute the script locally on the machine &#8211; this way you may see the error. One of the possibilities is that the DB is in use and cannot be detached &#8211; make sure SQL Management Studio is not logged to the DB.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SU</title>
		<link>http://www.linglom.com/2009/01/29/automate-backup-database-on-sql-server-part-i-create-vb-script/comment-page-1/#comment-5036</link>
		<dc:creator>SU</dc:creator>
		<pubDate>Mon, 11 Jan 2010 12:40:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.linglom.com/?p=597#comment-5036</guid>
		<description>hi,

i have not got any logs in the sql server or in the evetnviewer pertaining to this backup !

could anybody help me out please....</description>
		<content:encoded><![CDATA[<p>hi,</p>
<p>i have not got any logs in the sql server or in the evetnviewer pertaining to this backup !</p>
<p>could anybody help me out please&#8230;.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
