<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>TheBernharts.com &#187; sql</title>
	<atom:link href="http://www.thebernharts.com/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thebernharts.com</link>
	<description>This, that, and the other thing.</description>
	<lastBuildDate>Sun, 18 Dec 2011 21:14:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
<link rel="http://api.friendfeed.com/2008/03#sup" xmlns="http://www.w3.org/2005/Atom" type="application/json" href="http://friendfeed.com/api/public-sup.json#bc1147d041"/>		<item>
		<title>Restoring a SQL database to a new host with limited accessibility</title>
		<link>http://www.thebernharts.com/2009/09/restoring-a-sql-database-to-a-new-host-with-limited-accessibility/</link>
		<comments>http://www.thebernharts.com/2009/09/restoring-a-sql-database-to-a-new-host-with-limited-accessibility/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 19:36:16 +0000</pubDate>
		<dc:creator>Neil</dc:creator>
				<category><![CDATA[neil]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Microsoft SQL Server 2005]]></category>
		<category><![CDATA[mssql]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.thebernharts.com/?p=602</guid>
		<description><![CDATA[How I moved a backed up SQL 2005 database to a server hosted at godaddy. The new server did not allow restoring backups that were not stored on the hosted server, and I had no access to place the .BAK file on the hosted server. Interested? Read on...]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.thebernharts.com/wp-content/uploads/2009/09/sql.gif" rel="lightbox[602]"><img class="alignright size-medium wp-image-609" style="margin: 0 0 5px 5px;" title="sql" src="http://www.thebernharts.com/wp-content/uploads/2009/09/sql-300x212.gif" alt="sql" width="300" height="212" /></a>I&#8217;ve taken a side job for some extra cash, which involves some web development work, including MS SQL database stuff. Up until now, I&#8217;ve only worked on SQL databases that I have complete administrative access to&#8230; i.e., they are steps away from me and I&#8217;ve set them up personally. This means that I&#8217;m very comfortable with importing, exporting, backing up, restoring, etc&#8230;. up until this project.</p>
<p>Here&#8217;s the scenario: I have a .BAK file of the database that was hosted on a MSSQL Server 2005 at my previous employers data-center. I need to re-create that database on a hosted MS SQL Server 2005 system at GoDaddy.com. No worries, I thought. I will just create my new database, do a manual back up of it. Then restore it and point it to my .BAK file from the previous server. That concept is old-hat to me, as I&#8217;ve done it countless times&#8230; <span id="more-602"></span>on systems that I have complete control and access to. This time it&#8217;s on a server that I have limited access to. GoDaddy only permits SQL restores from files that were created by the host system, and stored on it&#8217;s local disk. And&#8230; I have no rights to place my .BAK file onto the host db server. So, I put on my thinking cap and thunk this one out.</p>
<p>Now, I must fully expose that I am not a SQL DBA in any way, shape, or form. Systems Administration is my background&#8230; I can install, configure, and maintain the heck out of a MS SQL database. But, I have extremely limited skills with SQL programming and queries. So, here&#8217;s what I came up with:</p>
<p>I have SQL 2005 Express running on my Vista system. Figured I could use that to my advantage here to get the data moved. I&#8217;ll break it down into pieces. I have SQL Express connected to my local instance, as well as the remote instance.</p>
<ul>
<li>Create a new database (in my local instance, I created a new database&#8230; we&#8217;ll call it dbFOO)</li>
<li>Make a back up of dbFOO</li>
<li>Do a restore of dbFOO, and change it to grab the data from the .BAK file from the old system (this is the step that I would have loved to be able to do on the remote database server)
<ul>
<li>Change the options so that it overwrites the existing database</li>
</ul>
</li>
<li>On the remote instance, create a new database named dbFOO (db names must be the same since we&#8217;re using some queries and we want to limit how much manual editing we need to do)</li>
<li>On the local instance, right-click on one of the tables and choose &#8220;Script Table as&#8230; &gt; CREATE To &gt; Clipboard&#8221;</li>
<li>On the remote instance, right-click on the database and choose &#8220;New Query&#8221;</li>
<li>In the query window, paste your clipboard contents
<ul>
<li>since your database names are the same, this query will run without issues on the remote instance.</li>
</ul>
</li>
<li>Execute the query. Boom, the table is now created on the remote instance. Rinse and repeat for the rest of the local instance tables.
<ul>
<li>Tip: keep that query window open, and just replace the sql script with the once for the next table and execute it. A little time-saver.</li>
</ul>
</li>
<li>Once the tables are created, right-click on the dbFOO database on the remote instance. Choose &#8220;Tasks &gt; Import Data&#8221;
<ul>
<li>WAIT! SQL Express doesn&#8217;t have DTS built in, so how am I able to do this? I once had SQL 2000 Ent. Mgr. installed and I held on to the admin tools, which included DTS. It does spit out some errors when starting up, but I just launch dtswizard.exe and I&#8217;m able to use it for my SQL 2005 Express databases.</li>
</ul>
</li>
<li>Choose the local instance as your source, and your remote instance as your destination. Set up dbFOO as the database, of course.</li>
<li>Go through all of the wizard steps, choose the option for &#8220;copy data from one or more tables or views&#8221;.</li>
<li>Check the boxes for all the tables and make any adjustments. (I had to enable identity inserts)</li>
<li>Finish the wizard and blam, there is all of the data.</li>
</ul>
<p>Are there other ways to accomplish what I needed? Maybe so. Is this the most graceful way to accomplish what I needed? Probably not. Do I care? Nope&#8230; I got what I needed done. It actually took me longer to write this post than it did to do all the steps listed above.</p>
<p>If you have other ideas or ways that this could have been done, please leave a comment. I love to document this stuff for other out there that could be in the same pickle I was, to give them some ideas or help in their situation.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thebernharts.com/2009/09/restoring-a-sql-database-to-a-new-host-with-limited-accessibility/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:thumbnail url="http://www.thebernharts.com/wp-content/uploads/2009/09/sql-150x150.gif" />
		<media:content url="http://www.thebernharts.com/wp-content/uploads/2009/09/sql.gif" medium="image">
			<media:title type="html">sql</media:title>
			<media:thumbnail url="http://www.thebernharts.com/wp-content/uploads/2009/09/sql-150x150.gif" />
		</media:content>
	</item>
	</channel>
</rss>

