Using T-SQL Functions and Summarizing Results

Functions in a SELECT statement

Your browser needs to be JavaScript capable to view this video

Try reloading this page, or reviewing your browser settings

This video is a brief description of using functions in a SELECT statement.

Keywords

  • Functions
  • Grouping
  • Select
  • Properties
  • Tables
  • T-SQL
  • SQL

About this video

Author(s)
John Deardurff
First online
03 March 2019
DOI
https://doi.org/10.1007/978-1-4842-4548-4_1
Online ISBN
978-1-4842-4548-4
Publisher
Apress
Copyright information
© John Deardurff 2019

Video Transcript

In this video segment, we will discuss using functions in the SELECT statement.

So what is a function? A function will allow your T-SQL code to perform specific tasks. For example, let’s say my friend Sally wants a cup of coffee. She says, John, can you go get me a cup of coffee? I would say, sure. Do you want cream or sugar with that? For me to get the cup of coffee for Sally, I would need to have the correct parameters to properly complete that task.

Unfortunately, there is not a get coffee function within SQL Server. But there are hundreds of other built in system functions that we can use to make our day easier, such as the substring function.

The substring function has three parameters or arguments. The first is a string of characters I want to work with. This can be literal text, like I have in this example. Or it could be a column from a table.

The second argument is letting the function know where to start selecting text. In this case, it will start with the second letter.

The last parameter is where I tell the substring function how many characters to return in total. If I ran this code, SQL would return the word press.

As I mentioned, there are hundreds of system functions built into SQL Server. In this video series, we will cover some of the most common functions. However, you can find out even more about the system built in functions over at docs.microsoft.com.