T-SQL tutorial: Creating a database
The first thing you will need to do after installing SQL Server is creating a database, tables and inserting data into these tables. This is the most boring lesson, but it is necessary to do the next exercises.
Introduction
After creating a database and tables we can start learning the basics of T-SQL. In this lesson you will learn a few things: unnamed blocks, comments, variables, expression, parameters, assigning query results to variables, CASE function, WHILE, BREAK, CONTINUE.
Views
View is a virtual table whose columns and rows are defined by a query. The two most important aspects of views are-
- To focus, simplify, and customize the perception each user has of the database.
- As a security mechanism by allowing users to access data through the view, without granting the users permissions to tables.
Stored procedures
The real power of T-SQL language is really the ability to create stored procedures. Stored procedures are executable objects stored in a database (one or more SQL statements that have been precompiled into a single executable procedure).
User-Defined Functions
If you can create procedures, you can also create functions. You can create the function once, store it in the database, and call it any number of times in your application. User-defined functions (UDF) can be modified independently of the application source code. In this lesson, you will learn how to create functions.
Cursors
Cursor is another type of object available in T-SQL that allows you to work on a single row and change the rows sequentially.
Triggers
A trigger is an object that is activated when a specific event occurs. In this lesson, you will get to know the triggers types, learn how to create and use them.