<?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>Software Warlock &#187; SQL</title>
	<atom:link href="http://softwareblog.morlok.net/category/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://softwareblog.morlok.net</link>
	<description></description>
	<lastBuildDate>Sat, 24 Dec 2011 16:06:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Getting DOC&gt; output when running script in SQL*Plus</title>
		<link>http://softwareblog.morlok.net/2011/08/15/getting-doc-output-when-running-script-in-sqlplus/</link>
		<comments>http://softwareblog.morlok.net/2011/08/15/getting-doc-output-when-running-script-in-sqlplus/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 16:37:51 +0000</pubDate>
		<dc:creator>Warlock</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[SQL*Plus]]></category>

		<guid isPermaLink="false">http://softwareblog.morlok.net/?p=427</guid>
		<description><![CDATA[Just ran across a problem where I would run a script that worked fine in Oracle SQL Developer, but didn&#8217;t work in SQL*Plus. When I&#8217;d load the script, I&#8217;d see parts of the script output back to me even though &#8230;<p class="read-more"><a href="http://softwareblog.morlok.net/2011/08/15/getting-doc-output-when-running-script-in-sqlplus/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Just ran across a problem where I would run a script that worked fine in <a href="http://www.oracle.com/technetwork/developer-tools/sql-developer/overview/index.html">Oracle SQL Developer</a>, but didn&#8217;t work in SQL*Plus. When I&#8217;d load the script, I&#8217;d see parts of the script output back to me even though I had echo off:</p>
<pre>
SQL> @ "foo.sql"
DOC>
DOC>  -- The GUID of the document i
DOC>  doc_guid varchar2(33) not null
DOC>);
DOC>
DOC>create table mx_values (
DOC>  mx_values_id varchar2(33) not null primary key,
DOC>  value_id integer not null,
</pre>
<p>The problem turned out to be caused by having newlines in my SQL commands. E.g.:
<pre name="code" class="sql">
CREATE TABLE foo (
  -- The id of the foo
  id integer not null,

  -- The data of the foo
  data varchar2(200) not null
);
</pre>
<p>I did this to provide visual breaks in the code. SQL Developer was fine with it, but SQL*Plus blew up. My solution was to just make the empty lines comments using the <tt>--</tt> comment syntax.</p>
]]></content:encoded>
			<wfw:commentRss>http://softwareblog.morlok.net/2011/08/15/getting-doc-output-when-running-script-in-sqlplus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Error with MySQL 5.5.8 on OS X</title>
		<link>http://softwareblog.morlok.net/2011/01/26/error-with-mysql-5-5-8-on-os-x/</link>
		<comments>http://softwareblog.morlok.net/2011/01/26/error-with-mysql-5-5-8-on-os-x/#comments</comments>
		<pubDate>Thu, 27 Jan 2011 02:33:04 +0000</pubDate>
		<dc:creator>Warlock</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://softwareblog.morlok.net/?p=423</guid>
		<description><![CDATA[I just installed MySQL 5.5.8 on my Mac and ran into problems when I tried to start it from the preferences pane. Looking in the console logs, I found the following message: 1/26/11 26 Jan 8:13:49 PM [0x0-0x1c61c6].com.apple.systempreferences[88942] /usr/local/mysql/support-files/mysql.server: line &#8230;<p class="read-more"><a href="http://softwareblog.morlok.net/2011/01/26/error-with-mysql-5-5-8-on-os-x/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>I just installed MySQL 5.5.8 on my Mac and ran into problems when I tried to start it from the preferences pane.  Looking in the console logs, I found the following message:</p>
<p><tt>1/26/11  26 Jan 8:13:49 PM	[0x0-0x1c61c6].com.apple.systempreferences[88942]	/usr/local/mysql/support-files/mysql.server: line 256: my_print_defaults: command not found</tt></p>
<p>A <a href="http://bugs.mysql.com/bug.php?id=53232">MySQL bug thread</a> suggested that the server could be started directly:</p>
<p><tt>sudo /usr/local/mysql/support-files/mysql.server start</tt></p>
<p>however, I got the same error:</p>
<p><tt>$ sudo /usr/local/mysql/support-files/mysql.server start<br />
/usr/local/mysql/support-files/mysql.server: line 256: my_print_defaults: command not found<br />
Starting MySQL<br />
 ERROR! Couldn't find MySQL server (./bin/mysqld_safe)</tt></p>
<p>Later in that <a href="http://bugs.mysql.com/bug.php?id=53232">same bug thread</a>, the actual solution can be found. The problem was a recent update to the mysql.server script. By manually specifying the install location of MySQL on mysql.server line 46:</p>
<p><tt>basedir=/usr/local/mysql</tt></p>
<p>the problem is resolved
<p><tt>$ sudo /usr/local/mysql/support-files/mysql.server start<br />
Starting MySQL<br />
 SUCCESS!<br />
</tt></p>
<p>This also corrects the problem with the preference pane.</p>
]]></content:encoded>
			<wfw:commentRss>http://softwareblog.morlok.net/2011/01/26/error-with-mysql-5-5-8-on-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Determining SQL Server Version Number</title>
		<link>http://softwareblog.morlok.net/2009/08/03/determining-sql-server-version-number/</link>
		<comments>http://softwareblog.morlok.net/2009/08/03/determining-sql-server-version-number/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 19:12:33 +0000</pubDate>
		<dc:creator>Warlock</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[nested decimal]]></category>
		<category><![CDATA[version number]]></category>

		<guid isPermaLink="false">http://softwareblog.morlok.net/?p=307</guid>
		<description><![CDATA[I&#8217;ve recently had to write some conditional SQL depending on which version of SQL Server I was running on. This MSDN article shows that for modern versions of SQL Server, the following will get the full version number: SELECT SERVERPROPERTY('productversion'); &#8230;<p class="read-more"><a href="http://softwareblog.morlok.net/2009/08/03/determining-sql-server-version-number/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>
I&#8217;ve recently had to write some conditional SQL depending on which version of SQL Server I was running on.
</p>
<p><a href="http://support.microsoft.com/kb/321185">This</a> MSDN article shows that for modern versions of SQL Server, the following will get the full version number:</p>
<pre name="code" class="SQL">
SELECT SERVERPROPERTY('productversion');
</pre>
<p>The problem with this is that it is in a string format (FYI you will need to cast it to VARCHAR), and it uses nested decimal notation (e.g. <tt>10.0.1600.22</tt> for SQL Server 2008).  This format is very difficult to reason with, as what I am looking to do is conditionally execute SQL for SQL Server 2000 and for everything else execute some other SQL.  I don&#8217;t care about minor revisions or service packs. To my knowledge, Microsoft does not provide any functions to work with nested decimals.</p>
<p>To make things easier, I constructed the following SQL to pull the major version number out of the string, convert it to an integer, and stick it in a variable:</p>
<pre name="code" class="SQL">
DECLARE @MajorVersion int
SELECT  @MajorVersion = CAST(substring(CAST(SERVERPROPERTY('productversion') AS VARCHAR), 0, Charindex('.', CAST(SERVERPROPERTY('productversion') AS VARCHAR))) AS int);
</pre>
<p>Messy, I know.  If anyone else has a better method, please leave it in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://softwareblog.morlok.net/2009/08/03/determining-sql-server-version-number/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

