Select Data  «Prev  Next»
Lesson 1

Select Data in SQL Server

In the last module, you learned about the basics of queries. You learned how to execute your queries, and how to incorporate logic, system catalogs, and more.
This module dives into selecting data from your databases. What would be the point of having data in your database if you can not get it out? This module is going to teach you how to do that.

Learning objectives

After completing this module, you will be able to:
  1. Construct inner and outer joins
  2. Alias your table and column names
  3. Construct union queries
  4. Write subqueries and understand when they are used
  5. Write aggregated queries
  6. Write union queries
  7. Apply additional keywords that can be used in your queries
  8. Write distributed select statements
In the next lesson, you will get an overview of the SELECT statement, which is used to retrieve data from your tables.

User-Defined Functions

(UDFs) User-defined functions have a tremendous number of similarities to sprocs, except that they: Can return a value of most SQL Server data types. Excluded return types include text, ntext, image, cursor, and timestamp. Cannot have side effects and basically, they cannot do anything that reaches outside the scope of the function, such as changing tables, sending e-mails, or making system or database parameter changes. UDFs are similar to the functions that you would use in a standard programming language such as VB.NET or C++. You can pass more than one variable in and get a value out. SQL Server's UDFs vary from the functions found in many procedural languages, in that all variables (except table with passing in variables By Ref or passing in pointers, sorry, there is no equivalent here. There is, however, some good news in that you can return a special data type called a table.
SQL Server 2017 Query Performance Tuning