Download SQL Server Developer Edition

Microsoft Website

Install that first.

Download SSMS

Microsoft Website

Install that second.

Download a sample database

Brent Ozar’s Stack Overflow

Follow the directions to attach the database.

Congratulations, you now have a full size database as your own personal sandbox to play in!

Optional: Containerized!

A different, somewhat more advanced approach to a test environment.


Online Query Sharing

db<>fiddle

db-fiddle

sqlfiddle


Basic Training Resources

SQLBolt - Learn SQL

SQL Discord

SQL Server Training & Consulting for DBAs & Developers

How to Think Like the SQL Server Engine

Logical processing order of the SELECT statement - Microsoft


Suggested Beginner’s Best Practices

  • Use white space and line breaks to make your query easier to read.
  • Specify the fields in your SELECT. Don’t just rely on SELECT * to pull back every column in the table.
  • Specify your JOIN types. INNER JOIN and LEFT OUTER are the two most common starting points.
  • Specify the conditions of your JOIN with the ON statement. How are your two tables related to each other? Don’t make us guess.
  • Alias your tables to make your query easier to write and read. Aliases can be very short or descriptive.
  • Learn about SET XACT_ABORT and whether you need it for your SP to behave the way you think it should
  • Define good datatypes (not over sized for no reason)
  • Make sure parameters and variables you are comparing against columns match datatypes.
  • Functions can kill your query performance, try not to rely on them. If you do, use them outside of/prior to your big queries.
SELECT A.col1, A.col2, A.col3, B.col1, B.col2, B.col3
FROM TableA AS A
INNER JOIN TableB AS B
ON A.someID = B.someID;

Other Sample Database Options

Most RDBMS come with some form of sample database. Here is the documentation for Microsoft SQL Server


<
Blog Archive
Archive of all previous blog posts
>
Next Post
Advent of Code Challenge