<?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>Cerebral Mastication &#187; sql server</title>
	<atom:link href="http://www.cerebralmastication.com/tag/sql-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cerebralmastication.com</link>
	<description>Something to Chew On</description>
	<lastBuildDate>Wed, 07 Dec 2011 13:08:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Connecting to SQL Server from R using RJDBC</title>
		<link>http://www.cerebralmastication.com/2010/09/connecting-to-sql-server-from-r-using-rjdbc/</link>
		<comments>http://www.cerebralmastication.com/2010/09/connecting-to-sql-server-from-r-using-rjdbc/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 18:00:26 +0000</pubDate>
		<dc:creator>JD Long</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[sql server]]></category>

		<guid isPermaLink="false">http://www.cerebralmastication.com/?p=891</guid>
		<description><![CDATA[A few months ago I switched my laptop from Windows to Ubuntu Linux. I had been connecting to my corporate SQL Server database using RODBC on Windows so I attempted to get ODBC connectivity up and running on Ubuntu. ODBC on Ubuntu turned into an exercise in futility. I spent many hours over many days [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cerebralmastication.com/wp-content/uploads/2010/09/sql_server_2008_logo.png"><img class="alignleft size-medium wp-image-901" style="border: 2px solid black; margin: 3px;" title="sql_server_2008_logo" src="http://www.cerebralmastication.com/wp-content/uploads/2010/09/sql_server_2008_logo-300x187.png" alt="" width="235" height="146" /></a>A few months ago I switched my laptop from Windows to Ubuntu Linux. I had been connecting to my corporate SQL Server database using RODBC on Windows so I attempted to get ODBC connectivity up and running on Ubuntu. ODBC on Ubuntu turned into an exercise in futility. I spent many hours over many days and never was able to connect from R on Ubuntu to my corp SQL Server.</p>
<p><a href="http://www.fosstrading.com/" onclick="pageTracker._trackPageview('/outgoing/www.fosstrading.com/?referer=');">Joshua Ulrich</a> was kind enough to help me out by pointing me to <a href="http://www.rforge.net/RJDBC/" onclick="pageTracker._trackPageview('/outgoing/www.rforge.net/RJDBC/?referer=');">RJDBC</a> which scared me a little (I&#8217;m easily spooked) because it involves Java. The only thing I know about Java is every time I touch it I <a href="http://stackoverflow.com/questions/3311940/r-rjava-package-install-failing" target="_blank" onclick="pageTracker._trackPageview('/outgoing/stackoverflow.com/questions/3311940/r-rjava-package-install-failing?referer=');">spend days trying to get environment variables</a> loaded just exactly the way it wants them. But Josh assured me that it was really not that hard. Here&#8217;s the short version:</p>
<p><a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=a737000d-68d0-4531-b65d-da0f2a735707&amp;displaylang=en" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.microsoft.com/downloads/en/details.aspx?FamilyID=a737000d-68d0-4531-b65d-da0f2a735707_amp_displaylang=en&amp;referer=');">Download the RJDBC driver from Microsoft</a>. There&#8217;s Win and *nix versions, so grab which ever you need. Unpack the driver in a known location (I used /etc/sqljdbc_2.0/). Then access the driver from R like so:</p>
<pre>require(RJDBC)
drv &lt;- JDBC("com.microsoft.sqlserver.jdbc.SQLServerDriver",
  "/etc/sqljdbc_2.0/sqljdbc4.jar") 
  conn &lt;- dbConnect(drv, "jdbc:sqlserver://serverName", "userID", "password")
#then build a query and run it
sqlText &lt;- paste("
   SELECT * FROM myTable
  ", sep="")
queryResults &lt;- dbGetQuery(conn, sqlText)</pre>
<p>I have a few scripts that I want to run on both my Ubuntu laptop and my Windows Server. To accommodate that I made my scripts compatible with both by doing the following to my drv line:</p>
<pre>if (.Platform$OS.type == "unix"){
         drv &lt;- JDBC("com.microsoft.sqlserver.jdbc.SQLServerDriver",
         "/etc/sqljdbc_2.0/sqljdbc4.jar")
} else {
         drv &lt;- JDBC("com.microsoft.sqlserver.jdbc.SQLServerDriver",
        "C:/Program Files/Microsoft SQL Server JDBC Driver 3.0/sqljdbc_3.0
         /enu/sqljdbc4.jar")
 }</pre>
<p>Obviously if you unpacked your drivers in different locations you&#8217;ll need to molest the code to fit your life situation.</p>
<p><span style="color: #ff6600;"><strong>EDIT: </strong>A MUCH better place to put the JDBC drivers in Ubuntu would be the /opt/ path as opposed to /etc/ which I used above. In Ubuntu the /opt/ directory is where one should put user executables and /etc/ should be reserved for packages installed by apt. I&#8217;m not familiar with all the conventions in Ubuntu (or even Linux in general) so I didn&#8217;t realize this until I got some reader feedback. </span></p>
<p>Be forewarned, RJDBC is pretty damn slow and it appears to no longer be in active development. For my use case, RODBC was clearly faster. But RJDBC works for me in Ubuntu and that was my biggest need.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cerebralmastication.com/2010/09/connecting-to-sql-server-from-r-using-rjdbc/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>More on Databases for Analytics</title>
		<link>http://www.cerebralmastication.com/2009/03/more-on-databases-for-analytics/</link>
		<comments>http://www.cerebralmastication.com/2009/03/more-on-databases-for-analytics/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 13:56:56 +0000</pubDate>
		<dc:creator>JD Long</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[column oriented]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[LucidDB]]></category>
		<category><![CDATA[SAS]]></category>
		<category><![CDATA[sql server]]></category>

		<guid isPermaLink="false">http://www.cerebralmastication.com/?p=235</guid>
		<description><![CDATA[Lately I have been struggling for what type of database to use for my analytics work. SQL Server is a really good database but I always get the feeling it was built for stuff other than what I want to do with it. I keep feeling like I am digging post holes with a spade [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I have been <a href="http://www.cerebralmastication.com/?p=212">struggling for what type of database </a>to use for my analytics work. SQL Server is a really good database but I always get the feeling it was<a href="http://" onclick="pageTracker._trackPageview('/outgoing/?referer=');"> </a>built for stuff other than what I want to do with it. I keep feeling like I am digging post holes with a spade and I keep thinking, &#8220;there should be a tool that does this better.&#8221;</p>
<p>Yesterday I was listening to the IT Conversations Podcast and heard a presentation given by <a href="http://itc.conversationsnetwork.org/shows/detail4009.html" onclick="pageTracker._trackPageview('/outgoing/itc.conversationsnetwork.org/shows/detail4009.html?referer=');">Michael Stonebraker from the Money:Tech conference</a>. Stonebraker (I keep wanting to call him Ballbuster) talks about how the elephant database engines (SQL Server, Oracle, DB2, etc) are never going to make it in financial trading engines because their approach to databasing (like freebasing only with data) is antiquated. It hit me when I was listening to the presentation that I don&#8217;t really know about the different types of databases. I&#8217;ve always wondered why SAS can be so damn fast at certain database functions and Oracle or SQL Server so slow at the same thing. I understand a little better now. I&#8217;ve been trying to <a href="http://stackoverflow.com/questions/571750/make-sql-server-faster-at-manipulating-data-turn-off-transaction-logging" onclick="pageTracker._trackPageview('/outgoing/stackoverflow.com/questions/571750/make-sql-server-faster-at-manipulating-data-turn-off-transaction-logging?referer=');">get SQL Server to act </a>like some other kind of DB, when in reality I just need a different type of DB&#8230; like a column oriented DB, maybe.</p>
<p>Since I don&#8217;t need the type of super high performance DB that Ballbuster talks about, I am wondering if I can efficiently use some type of open source <a href="http://en.wikipedia.org/wiki/Column-oriented_DBMS" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Column-oriented_DBMS?referer=');">Column Oriented DB</a>. But I have a lot of investment in learning SQL which I would like to not lose. Looks like I need to research my options.</p>
<p>Below are some sources for database technology information beyond the big three elephants:</p>
<ul>
<li><a href="http://thinkwaitfast.blogspot.com/" onclick="pageTracker._trackPageview('/outgoing/thinkwaitfast.blogspot.com/?referer=');">John Sichi&#8217;s blog</a>. He is the co-founder of <a href="http://www.luciddb.org/" onclick="pageTracker._trackPageview('/outgoing/www.luciddb.org/?referer=');">LucidDB</a></li>
<li><a href="http://julianhyde.blogspot.com/" onclick="pageTracker._trackPageview('/outgoing/julianhyde.blogspot.com/?referer=');">Julian Hyde&#8217;s Blog </a>- Founder of the <a href="http://sourceforge.net/projects/mondrian/" onclick="pageTracker._trackPageview('/outgoing/sourceforge.net/projects/mondrian/?referer=');">Mondrian </a>open-source OLAP engine, and chief architect of the <a href="http://www.sqlstream.com/index.html" onclick="pageTracker._trackPageview('/outgoing/www.sqlstream.com/index.html?referer=');">SQLstream </a>streaming SQL engine</li>
<li><a href="http://www.databasecolumn.com/" onclick="pageTracker._trackPageview('/outgoing/www.databasecolumn.com/?referer=');">The Database Column </a>- A multi-author blog on database technology and innovation.</li>
</ul>
<p>More to come on this topic&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cerebralmastication.com/2009/03/more-on-databases-for-analytics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Choosing an SQL Engine for Analytics</title>
		<link>http://www.cerebralmastication.com/2009/03/chosing-an-sql-engine-for-analytics/</link>
		<comments>http://www.cerebralmastication.com/2009/03/chosing-an-sql-engine-for-analytics/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 21:37:57 +0000</pubDate>
		<dc:creator>JD Long</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[firebird]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[sql server]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://www.cerebralmastication.com/?p=212</guid>
		<description><![CDATA[I&#8217;ve been struggling for a while on which database to use for my working data. I used to use MS Access quite a lot. The problems with MS Access include but are not limited to:

2 GB file size limit, at least historically
Versions change with each edition of MS Office
Sort of tough to write SQL scripts
Very [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been struggling for a while on which database to use for my working data. I used to use MS Access quite a lot. The problems with MS Access include but are not limited to:</p>
<ul>
<li>2 GB file size limit, at least historically</li>
<li>Versions change with each edition of MS Office</li>
<li>Sort of tough to write SQL scripts</li>
<li>Very little automation, ie compression, backup, etc.</li>
<li>Windows only</li>
</ul>
<p>I used Oracle for a few years as a result of my previous employer being an Oracle shop. I then switched to SQL Server when I changed jobs. A full blown client/server DB really does not make a lot of sense for much of what I do. I don&#8217;t run a transactional data store. I don&#8217;t need to have dozens of users hooked to the DB. And I do sometimes need access to my data when I am not hooked to the mother-ship. So I could run the free version of SQL Server on my laptop or run MySQL on my laptop, but both of these options rub me the wrong way. Why? I do a lot of data analysis in R which is RAM intensive. Running a DB server on my laptop means that some fraction of my RAM is going to be taken up by the db server software which is hanging out waiting for me to throw requests at it. I could manually hack around this by starting the server before I load data and then killing it after the data is loaded. That&#8217;s just too big of a pain in my rectum. Oh yeah, one more design requirement: I want to be able to push the whole DB out to a storage blob at Amazon and pound on it using EC2 machines, running Linux. Plus I am cheap and don&#8217;t want to pay a lot.</p>
<p>I&#8217;ll probably end up with a model where I keep some master data sets on a client/server DB and then I will replicate chunks of that to my laptop into my serverless db. I&#8217;ll probably also put output from my desktop db back into the server after analytic work is  done.</p>
<p>I knew about SQLite because of an <a href="http://www.twit.tv/floss26" onclick="pageTracker._trackPageview('/outgoing/www.twit.tv/floss26?referer=');">interview with its author, Richard Hipp on FLOSS Weekly</a>. There&#8217;s also a <a href="http://video.google.com/videoplay?docid=-5160435487953918649" onclick="pageTracker._trackPageview('/outgoing/video.google.com/videoplay?docid=-5160435487953918649&amp;referer=');">video of Hipp talking at the Googleplex</a>. I wish that guy was my neighbor. He seems like the type of guy who would shovel your walk for you then apologize for not doing it perfectly by sending over homemade cookies. Unrelated to the cookies, I really like that SQLite is <a href="http://en.wikipedia.org/wiki/Type_system#Strong_and_weak_typing" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Type_system_Strong_and_weak_typing?referer=');">weakly typed</a>.  I&#8217;m a free spirit like that.</p>
<p>I did some digging for SQLite alternatives and came up with <a href="http://stackoverflow.com/questions/417917/alternatives-to-sqlite" onclick="pageTracker._trackPageview('/outgoing/stackoverflow.com/questions/417917/alternatives-to-sqlite?referer=');">some stuff at StackOverflow</a>. You can read the post but it reminded me of Firebird. I&#8217;m immediately drawn to FireBird since their logo looks so dang much like the Ruger logo:</p>
<p><img class="alignleft size-full wp-image-214" title="downloads" src="http://www.cerebralmastication.com/wp-content/uploads/2009/03/downloads.jpg" alt="downloads" width="327" height="76" /></p>
<p><img class="alignleft size-full wp-image-215" title="fb-facts" src="http://www.cerebralmastication.com/wp-content/uploads/2009/03/fb-facts.png" alt="fb-facts" width="312" height="70" /></p>
<p>But is Firebird able to be run severless?  If I have to install a server then I would just as well run MySQL.</p>
<p><a href="http://www.oracle.com/database/berkeley-db/index.html" onclick="pageTracker._trackPageview('/outgoing/www.oracle.com/database/berkeley-db/index.html?referer=');">Berkeley DB </a>seems like another option worth investigating, although I am not sure if I can use it without really embedding it in another program the way that I can with SQLite.</p>
<p>SQLite gets bonus points for having native R drivers meaning that I don&#8217;t have to go through a connector technology like ODBC. This is important enough that I should probably make that a requirement. I think Berekley DB has support in R as well. I know for a fact that writing back to SQL Server through the R ODBC package (RODBC) is like pushing a car with a rope, but only slower. Plus I don&#8217;t know how to make ODBC work on Linux. Not rocket science, I am sure, but still one more thing I would have to learn before I do that which I am paid to do.</p>
<p>I&#8217;m going to do some testing, but it looks like I should test real life performance of SQLlite and Firebird with my data.  More to come on this, I am sure.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cerebralmastication.com/2009/03/chosing-an-sql-engine-for-analytics/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

