How To Use User Defined Functions in Expressions?
Submitted by: AdministratorAn 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
Submitted by: Administrator
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
Submitted by: Administrator
Read Online MS SQL Server Job Interview Questions And Answers
Top MS SQL Server Questions
☺ | How To Select Some Specific Rows from a Table in MS SQL Server? |
☺ | What Happens If You Insert a Duplicate Key for the Primary Key Column in MS SQL Server? |
☺ | How To Execute the Cursor Queries with "OPEN" Statements? |
☺ | PHP MSSQL - How To Display a Past Time in Days, Hours and Minutes? |
☺ | How to Create a View using Data from Another View? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Sybase Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |