Beginning Learning SQL Server (2008 R2 or 2012)

For SQL Server 2008 R2 and SQL Server 2012 , going in it to it with no knowledge of what exactly SQL is can be kind of intimidating. I know this first hand as my job – in working with my current job, I had little no experience with Microsoft SQL – I had worked with MySQL in the past, but let me be the first, and certainly not the last to tell you that there is a massive difference between the two. SQL has been around for quite some time and is more or less an abbreviation. SQL (said something like “see kwul”) means Structured Query Language. If you have come here to learn the absolute basics of what SQL is, sadly I am not going to help much. I suggest Wikipedia for all that info – but I am just going to go over some basics.

Installing SQL – before we start with this entire tutorial on how exactly I learned SQL, I would suggest you build yourself a SQL Server instance. You need to have a version of SQL that you can work with, a copy of some form of Windows (Windows Server 2008 or 2008 R2 would work best) and maybe stick it in a VM using something like VMware Player or VirtualBox. If you are on a Linux host, you’ll want to use Virtualbox – either available from your repository (might be outdated) or else straight from Virtualbox.org. If you feel confident that you can learn SQL in 120 days, I believe Microsoft has a 120 day Trial for SQL Server 2012 on their site.

Anyway – for all these examples in here, you are going to need a full working copy of SQL Server (at least Standard, if not Enterprise) and preferably not in a production environment – hence why I would just suggest making a VM to house it – if you’re not doing heavy querying or have it taking massive CPU hits, a VM will work fine for setting this up. I’ve found that using a VM with 2 gigs of RAM does fine, provided this is just a box for learning and not a production box. Obviously if you are making a production box, you should probably consider more than a VM and more than 2 gigs of RAM.

The VM I created has 4 procs and 2 gigs of RAM – I’ve found that this will suffice for our learning sessions.

I’m going to assume that you know how to install Windows in a virtual environment and get it licensed properly. For all these examples in the coming weeks and months, I will be using Windows Server 2008 R2 Foundation with SQL Server 2012. For SQL Server 2008 and 2012, the querying language has not changed that much, and therefore all the queries that I will stick on here will work just fine in either 2008 R2 or 2012.

Alright, on to installing SQL. I’m not going to walk you through every last detail about installing SQL because I don’t know which environment you are in – I suggested using a VM, but perhaps you already have a stage server you can use. In any event, I would highly suggest reading through and following this guide to get your SQL instance all set up and running. This guide will help you set up a config that is good for your specific setting.

Once that is set up, you can go on to the next step – which is called “Creating our Learning Database”

Notepad++

In Linux, for the most part, you are lucky enough to have an awesome text editor. Be it gedit or kate, you’re lucky, because in Windows, you’re stuck with good old “Notepad” – which is extremely limited.

Enter Notepad++. Every kind of developer / editor / administrator will want this. Seriously. It opens just about anything – I’ve taken to sometimes writing SQL in it because it has built in SQL formatting. It natively opens XML, PHP, C++, and a whole mess of other file formats.

It is an extremely handy utility and I suggest you get it if you are running Windows in a development / sys admin environment, I highly recommend it.

http://notepad-plus-plus.org/

7-Zip

If you don’t use 7-zip, now is the time to get it. I use this tool a lot and I openly support it (in fact, for the most part, it’s the only compression utility I use – a lot of files that you may come across to download on this site will be straight up .7z). You’ll need 7-Zip for Windows to extract those. Luckily most Linux users won’t need much of anything if you are using a modern distro.

http://www.7-zip.org

Installing Eclipse to any Gnome Based Linux Distro

Problem – Eclipse is outdated in your repository, or else it’s not even in your repository.

Solution – install it from their site!

I have done this process in both RPM based and APT based distros and it works just fine. First thing you need to know though is that you need a JDK or JRE to run Eclipse. I personally have done it on CentOS (Stella), Fedora, Debian, Ubuntu (either Unity or Gnome), Mint (Mate, Cinnamon), etc… For some reason, I prefer Oracle’s JDK / JRE over OpenJDK / OpenJRE, but that is just a personal preference. I will write another article here in the future that tells how to install Oracles JDK. It tends to use less memory in my personal opinion, but that is pointless because I usually expand the memory that Eclipse can use.

I have never tried this with KDE, LXDE, or XFCE – so I’m not sure if it will work or not. I know it works on MATE, Unity, Cinnamon, and GNOME 2 and 3.

Here we go.

First you need to download the latest Eclipse (at the present it’s Juno) from http://www.eclipse.org. Choose Linux and choose your architecture (x86 or x64).

Next, open a terminal. This is where the fun starts. First you need to go to wherever your your downloads are. For most people this is in /home/user/Downloads or ~/Downloads

$ cd ~/Downloads

Next we need to untar Eclipse.

$ tar xvf eclipse*.tar.gz

This will create a folder in that folder called “eclipse”. Next we need to do this in this order. Become root first, or the rest will fail.

$ su
# mv eclipse /opt
chown -R root:root /opt/eclipse
chmod -R +r /opt/eclipse
touch /usr/bin/eclipse
chmod 755 /usr/bin/eclipse

Now we need edit /usr/bin/eclipse.

Use your favorite text editor  as super user (nano, vi, gedit, whatever):

# sudo gedit /usr/bin/eclipse

To punch this in to /usr/bin/eclipse

#!/bin/sh
export ECLIPSE_HOME="/opt/eclipse"
$ECLIPSE_HOME/eclipse $*

Next we need to make an application icon and launcher for it in the gnome menu. Use your favorite text editor to create /usr/share/applications/eclipse.desktop

# sudo gedit /usr/share/applications/eclipse.desktop

Add this to that file:

[Desktop Entry]
Encoding=UTF-8
Name=Eclipse
Comment=Eclipse IDE
Exec=/usr/bin/eclipse
Icon=/opt/eclipse/icon.xpm
Terminal=false
Type=Application
Categories=GNOME;Application;Development;
StartupNotify=true

And there you go. You can now launch Eclipse from the “Programming” section of Gnome 2 – if you are running Mate, Cinnamon, or Gnome 3, just search for Eclipse.

Issues:

I have had an issue in the past where no repositories will show up in Eclipse. You’ll have to manually add the latest repository – Name it Juno and add the link http://download.eclipse.org/releases/juno – then it will work for you.

I’ve also sometimes had an issue where the launcher we created at /usr/bin/eclipse doesn’t work. If that is your case, in eclipse.desktop, change the Exec= line to this:

Exec=/opt/eclipse/eclipse

And that should work for you.