Introduction to Data Selection in SQL
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.
After completing this module, you will be able to:
- Construct inner and outer joins
- Alias your table and column names
- Construct union queries
- Write subqueries and understand when they are used
- Write aggregated queries
- Write union queries
- Apply additional keywords that can be used in your queries
- Write distributed select statements
In the next lesson, you will get an overview of the
statement, which is used to retrieve data from your tables.
(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.