A friend was interested in learning SQL, so I wanted to put together a reference to set up a learning environment.
The easiest course is to find an online resource to run SQL. A great resource is at SQL Fiddle. This will allow you to setup some tables in the Schema Panel, and then run commands in the query window.
I’ve posted a script at Github that will build and populate some simple tables to use as a data source. First, select the engine version to one of the SQL Server options (MS SQL Server 2012), the default is set to MySQL. Paste the code into the Schema Panel and click ‘Build Schema’. Once that’s completed, you can run SQL commands in the right-hand query window, and results will appear in the bottom pane.
SQL Server Express:
Another option would be to install the SQL Server tools locally to run commands.
SQL Server Express is available as a free download. From this page, select ‘Download’ and select ‘SQLEXPRWT_x64_ENU.exe’ (assuming you want the 64 bit install) then click ‘Next’. Make sure to get the edition with tools, to make sure you get SSMS. You can take most of the defaults, although I recommend choosing Mixed Authentication mode instead of Windows Authentication only.
Scott Hanselman also has a blog post to link to the download page.
Most examples seen for SQL Server are against the Adventureworks database. It is no longer included with the SQL Server install, but it is available to download.
Reference and Tutorials:
Zed Shaw has a great series of programming primers in the ‘Hard Way’ series. He has SQL resources available at SQL The Hard Way.
The best reference for T-SQL will be SQL Server Books Online.