user-defined function SQL Server


show more Creating a user-defined function provides you with in-depth training on Business. Taught by Martin Guidry as part of the SQL Server: Triggers, Stored Procedures, and Functions show less
please wait ...

Creating a user-defined function

Now I'd like to talk a little bit about functions, sometimes called user-defined functions in SQL Server 2012. I'm going to start off with creating a new function. So very similar to creating a stored procedure. We start off with the keyword CREATE and then the keyword FUNCTION. And then we need to give a name, typical naming rules in play here. After the name, you have to supply a list of parameters in parenthesis. So we could list out as many parameters as we want.

You also have the option to do zero parameters which if you'd like to do zero parameters, you still have to put the empty parenthesis, which I will do here. Next, we have to declare what type of data, this function is going to return. Every function will return something and we don't at this point have to decide the exact value we're returning, but we do have to decide what data type you're going to return. So are you going to return a date, a piece of text, a number? You have to make that decision at ...

Creating a user-defined function
Video duration: 4m 59s 1h 52m Advanced

Viewers:

Creating a user-defined function provides you with in-depth training on Business. Taught by Martin Guidry as part of the SQL Server: Triggers, Stored Procedures, and Functions

Subjects:
Business Developer IT
Software:
SQL Server
Author:
please wait ...