From the course: Microsoft SQL Server 2019 Essential Training

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Leverage user-defined scalar functions

Leverage user-defined scalar functions - SQL Server Tutorial

From the course: Microsoft SQL Server 2019 Essential Training

Leverage user-defined scalar functions

- [Instructor] If you find that you're processing a column of data in the same way on a regular basis and there isn't a built-in function to do the work for you, then you can often simplify the process by creating your own custom scalar function. Scalar functions are just a fancy way of saying a function that returns a single value. Most of SQL Server's built-in functions are scalar. The count function, for example. Doesn't matter how many records you feed into it, it'll always return just a single number. I'd like to create a custom function for our WideWorldImporters database. If I expand this open and then I expand the Tables folder, we're going to find a table here at the very bottom called Warehouse.VehicleTemperatures. I want to right-click on that and choose Select Top 1000 Rows. This table contains data from censors in a refrigerated delivery truck. The temperature column stores measurements in degrees Celsius, and…

Contents