MS SQL Server Concepts and Programming Question:

Download Job Interview Questions and Answers PDF

How To Use User Defined Functions in Expressions?

MS SQL Server Interview Question
MS SQL Server Interview Question

Answer:

An user defined function must return a value, which can be used in any expression as long as the return value data type matches the expression.

To execute a user defined function and use its return value in an expression, you just need to enter the schema name and the function name as a value in the expression. The tutorial exercise below shows you how use a user defined function in an expression:

-- Calling a function without schema name
PRINT 'Hi there, '+Welcome();
GO
Msg 195, Level 15, State 10, Line 1
'Welcome' is not a recognized built-in function name.

-- Calling a function with schema name
PRINT 'Hi there, '+dbo.Welcome();
GO
Hi there, Welcome to globalguideline.com

Download MS SQL Server Interview Questions And Answers PDF

Previous QuestionNext Question
How To Create a Simple User Defined Function in MS SQL Server?How To List All User Defined Functions in the Current Database?