Q&A

Q1:I tried to use a RAISERROR statement in the UDF to notify me about any errors. Why won't it work?
A1: A The RAISERROR and PRINT statements are not valid within a UDF. To detect any errors, you must use the RETURN statement and check for any errors when the UDF returns to the calling routine.
Q2:What can I use a user-defined function for?
A2: A user-defined function can be used to provide a complex calculation to all users of the database. This would prevent requiring everyone to create his own.

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.