Learn SQL Server for free on your PC at home!
Download SQL Server Developer Edition
Install that first.
Download SSMS
Install that second.
Download a sample database
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
Basic Training Resources
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
- SqlZOO
- LearnSQL
- SQLSkills
- Data repository collection at FiveThirtyEight
- Kaggle has a lot of sample options
- Automated Github repository of various datasets