<?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/"
	>

<channel>
	<title>Server Side Guy &#187; SQL</title>
	<atom:link href="http://serversideguy.com/category/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://serversideguy.com</link>
	<description>Just another Barsness Solutions weblog</description>
	<lastBuildDate>Tue, 31 Jan 2012 14:57:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How To Duplicate a PGSQL database</title>
		<link>http://serversideguy.com/2009/08/10/how-to-duplicate-a-pgsql-database/</link>
		<comments>http://serversideguy.com/2009/08/10/how-to-duplicate-a-pgsql-database/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 12:41:50 +0000</pubDate>
		<dc:creator>Tim Barsness</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PSQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[PostgreSQL]]></category>

		<guid isPermaLink="false">http://serversideguy.com/?p=80</guid>
		<description><![CDATA[Recently I needed to create a duplicate of PGSQL database.  Being a MySQL guy, I didn&#8217;t know off hand how to do it, but here is an easy way: pg_dump original_db &#62; original_db.sql createdb new_db psql -d new_db &#60; original_db.sql From a bird&#8217;s eye view, you are creating a dump of the original database and [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I needed to create a duplicate of PGSQL database.  Being a MySQL guy, I didn&#8217;t know off hand how to do it, but here is an easy way:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">pg_dump original_db <span style="color: #339933;">&gt;</span> original_db<span style="color: #339933;">.</span>sql
createdb new_db
psql <span style="color: #339933;">-</span>d new_db <span style="color: #339933;">&lt;</span> original_db<span style="color: #339933;">.</span>sql</pre></div></div>

<p>From a bird&#8217;s eye view, you are creating a dump of the original database and outputting it to a file.  From there, make sure the new database is created and use your dump file as input for that database.  It wouldn&#8217;t be too hard to make this into a one-liner, but I like to see intermediate steps to make sure things are going well.</p>
]]></content:encoded>
			<wfw:commentRss>http://serversideguy.com/2009/08/10/how-to-duplicate-a-pgsql-database/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SQL Server Error 3154</title>
		<link>http://serversideguy.com/2009/07/16/sql-server-error-3154/</link>
		<comments>http://serversideguy.com/2009/07/16/sql-server-error-3154/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 21:13:59 +0000</pubDate>
		<dc:creator>Tim Barsness</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://serversideguy.com/?p=47</guid>
		<description><![CDATA[I ran accross the SQL Server error 3154. In SQL Server 2008, it says &#8220;Restore Failed for Server &#8216;ServerName\InstanceName&#8217;&#8221; Additional Information: &#8220;System.Data.SQLClient.SqlError: The backup set holds a backup of a database other than the existing &#8216;dbname&#8217; database. (Microsoft.SqlServer.Smo)&#8221; Solution: Use WITH REPLACE.  This can be found in the GUI tool or done in T-SQL as [...]]]></description>
			<content:encoded><![CDATA[<p>I ran accross the SQL Server error 3154.  In SQL Server 2008, it says &#8220;Restore Failed for Server &#8216;ServerName\InstanceName&#8217;&#8221; Additional Information:  &#8220;System.Data.SQLClient.SqlError: The backup set holds a backup of a database other than the existing &#8216;dbname&#8217; database.  (Microsoft.SqlServer.Smo)&#8221;</p>
<h2>Solution:</h2>
<p>Use WITH REPLACE.  This can be found in the GUI tool or done in T-SQL as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">RESTORE</span> <span style="color: #0000FF;">DATABASE</span> dbname
<span style="color: #0000FF;">FROM</span> <span style="color: #0000FF;">DISK</span> <span style="color: #808080;">=</span> <span style="color: #FF0000;">'C:<span style="color: #000099; font-weight: bold;">\d</span>bname.bak'</span>
<span style="color: #0000FF;">WITH</span> <span style="color: #FF00FF;">REPLACE</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://serversideguy.com/2009/07/16/sql-server-error-3154/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Escaping Single Quotes in MS SQL Server (T-SQL)</title>
		<link>http://serversideguy.com/2009/06/02/escaping-single-quotes-in-ms-sql-server-t-sql/</link>
		<comments>http://serversideguy.com/2009/06/02/escaping-single-quotes-in-ms-sql-server-t-sql/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 15:33:27 +0000</pubDate>
		<dc:creator>Tim Barsness</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://serversideguy.com/?p=16</guid>
		<description><![CDATA[Escaping single quotes (&#8216;) in Transact-SQL is done by replacing the single quote with two single quotes. So: SELECT 'I went to Kinko''s' Returns &#8220;I went to Kinko&#8217;s&#8221; The only case where two consecutive single quotes don&#8217;t return a single quote is when the first one also starts the string.  In this case, if only [...]]]></description>
			<content:encoded><![CDATA[<p>Escaping single quotes (&#8216;) in Transact-SQL is done by replacing the single quote with two single quotes.  So:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">SELECT <span style="color: #0000ff;">'I went to Kinko'</span><span style="color: #0000ff;">'s'</span></pre></div></div>

<p>Returns &#8220;I went to Kinko&#8217;s&#8221;</p>
<p>The only case where two consecutive single quotes don&#8217;t return a single quote is when the first one also starts the string.  In this case, if only two single quotes are present, the second one ends the string and the return value is the empty string.  <a href="http://sqlblogcasts.com/blogs/madhivanan/archive/2008/02/19/understanding-single-quotes.aspx" target="_blank">SQL Blog Casts</a> has a good example of this.</p>
<h2>Doing the same in MySQL</h2>
<p>Escaping a single quote in MySQL is done by adding a backslash before it (\&#8217;)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">SELECT <span style="color: #0000ff;">'I went to Kinko\'s'</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://serversideguy.com/2009/06/02/escaping-single-quotes-in-ms-sql-server-t-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

