Day 20

Quiz

1:User-defined functions can return scalar values as well as tables and can be used as part of the SELECT statement or in the FROM clause of a query. True or False?
A1: True
2:What are the three different types of user-defined functions?
A2: The three types of UDFs are
  • Scalar—Returns a single value

  • Inline single table value—Returns a table of data from a single table

  • Multi-statement table value—Uses joins to return data in a table from multiple tables in the database>

3:Can I use a user-defined function instead of a view?
A3: Yes! In fact, by using a UDF instead of a view, performance will actually increase because the database does not have to maintain the view.

Exercise

1:Using the Northwind database, create a function that accepts a ...

Get Sams Teach Yourself Transact-SQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.