Stairway to T-SQL DML
This Stairway will provide you with a basic understanding of how to work with data from SQL Server tables, using SQL Server’s Transact-SQL (T-SQL) dialect. DML is the Data Manipulation Language, and is the aspect of the language dealing with the data. It includes the statements SELECT, INSERT, UPDATE and DELETE. This Stairway will as also provide some history of the SQL language and some general concepts about set theory. Each level will build upon the prior level, so by the time you are finished you will have a good understanding of how to select and modify data from SQL Server.
- There are lots of different aspects of managing data in a SQL Server database. Before you can get into the complex management issues associated with managing application data you need to start with the basic of retrieving data from a table. To return data from a SQL Server table you use a SELECT statement. In this level I will be cover the components of the basic SELECT statement and how you can use it to retrieve data from a single SQL Server table.
- Let’s step back in time and discuss the history of Structured Query Language, or what most SQL Server professionals just shorten to SQL. Fasten your seatbelts, crank up the time machine and travel back in time to follow the history of SQL and Microsoft SQL Server from its early years to where they are today.
- This level of the stairway details the creation of a relational database, as well as filling in some of the history of the relational database model.
- A relational database contains tables that relate to each other by key values. When querying data from these related tables you may choose to select data from a single table or many tables. If you select data from many tables, you normally join those tables together using specified join criteria. The concepts of selecting data from tables and joining tables together is all about managing and manipulating sets of data. In Level 4 of this Stairway we will explore the concepts of set theory and mathematical operators to join, merge, and return data from multiple SQL Server tables.
- Joining tables is a crucial concept to understanding data relationships in a relational database. When you are working with your SQL Server data, you will often need to join tables to produce the results your application requires. Having a good understanding of set theory, and the mathematical operators available and how they are used to join tables will make it easier for you to retrieve the data you need from SQL Server.
- In this Level you will see how to use the ORDER BY clause to return your data in a sorted order.
- In this article you will be see how to group data using the simple GROUP BY clause, in order to summarize more complex data.
- In this article I will be expanding on my discussion of the GROUP BY clause by exploring the ROLLUP, CUBE and GROUPING SETS operators. These additional GROUP BY operators make it is easy to have SQL Server create subtotals, grand totals, a superset of subtotals, as well as multiple aggregate groupings in a single SELECT statement.
- Not all applications are limited to only retrieving data from a database. Your application might need to insert, update or delete data as well. In this article, I will be discussing various ways to insert data into a table using an INSERT statement.
- Unless you are working on a reporting-only application you will probably need to update tables in your SQL Server database. To update rows in a table you use the UPDATE statement. In this level we will be discussing how to find and update records in your database, and discuss the pitfalls you might run into when using the UPDATE statement.
- You may have data in a database that was inserted into a table by mistake, or you may have data in your tables that is no longer of value. In either case, when you have unwanted data in a table you need a way to remove it. The DELETE statement can be used to eliminate data in a table that is no longer needed. In this article you will see the different ways to use the DELETE statement to identify and remove unwanted data from your SQL Server tables.
- The final level of this stairway looks at the MERGE statement in detail, focusing on how to perform insert, update and delete logic using the MERGE statement.