1.0: Getting Started with T-SQL

One of the flavors of SQL is T-SQL (Transact-SQL), which is used with MSSQL in Visual Studio. The Microsoft reference docs for T-SQL can be found here. If you are looking for general documentation regarding Visual Studio, you can follow this link.

In Part One, you will create a SQL Library to practice learning the basics of SQL. Rather than giving you step by step instructions, there will be challenges, tips, and requirements for the exercises you need to complete.

After completing Part One, you should have a better understanding of the following concepts:

  • Writing basic SQL queries in T-SQL

  • Creating tables with SQL

  • Inserting seed data

When you are finished, you’ll have a database that looks like this:

Since MSSQL is built in to Visual Studio, there are no additional programs that need to be installed. However, if you need to install Visual Studio, you can follow along with this video.

Once you have Visual Studio up and running, go to the "View" menu in the toolbar, and click on "SQL Server Object Explorer" as shown below. This will open a new window so you can view and access your databases.

Your screen should now look something like the image below. Don't worry if they are not identical. For example, you might not have a "Projects" folder, and that is fine.

Notice the icon circled in yellow. This icon will create a new query, which is where you will write your SQL statements. The icon is faded because this option is not currently available to you.

  • Click on the white triangle next to "SQL Server." This will show what servers you can access.

  • Click on the white triangle next to the server where your database is stored. It will start with "(localdb)\MSSQLLocalDB." This will expose three folders - "Databases," "Security," and "Server Objects."

  • Click on the triangle next to the "Databases" folder. This will show all the databases you can connect to.

  • Click on the database you want to work with. Once you have selected a database, you can create a new query; the icon circled in yellow is now accessible. Use the image below as a guide. Your screen will not look identical because you have different databases on your computer.

Clicking on the "New Query" icon will open a new window. This is where you will write your SQL statements.

Please continue to Part 1.1: Create Database.

Last updated