Scalar functions

- [Instructor] If you find that the built-in functions…don't meet your needs,…you can create your own function.…These are called user-defined functions.…I've staged some code for us that's going to do just that.…If you open up the exercise files…and copy all of that into a new query window,…you'll see we're using the keyword create…and the keyword function,…then the name of the function's going to be get email.…We'll pass one parameter to it called person name.…Then we have to specify what data type is going…to be returned by this function,…so I specified it returns a varchar of lith 250.…

We then have the logic for actually finding…an email address based on someone's name,…and then eventually we return that email address.…So I'll go ahead and click the execute button,…and we see command(s) completed successfully.…To find this function we'll look again in programmability,…open up functions in the scalar-valued function section.…I'll right click and hit refresh…and now we see dbo.getemail.…To demonstrate using this function,…

Resume Transcript Auto-Scroll

Author

Released

11/16/2016

SQL Server supports mission-critical applications and big data solutions—without having to buy expensive add-ons or high-end appliances. Learn the essentials of Microsoft's latest release, SQL Server 2016. Use tools like SQL Management Studio and the Configuration Monitor to deploy and manage databases both on premises and in the cloud. Learn how to create new databases, build tables, define relationships, write queries, and use stored procedures and built-in functions. Instructor Martin Guidry—a SQL Server veteran—also shows how to manipulate XML and JSON data, and perform crucial database administration tasks, such as backups and restores, security enhancements, and performance monitoring. Plus, find out how to extend SQL Server by integrating it with cloud services like Microsoft Azure.