Collections:
"CREATE FUNCTION" - Creating User Defined Functions in SQL Server
How To Create a Simple User Defined Function in SQL Server Transact-SQL?
✍: FYIcenter.com
If you want to create a simple user defined function, you can use the "CREATE FUNCTION" command with a statement block in a simple format as shown in below:
CREATE FUNCTION function_name()
RETURNS data_type
AS BEGIN
statement_1;
statement_2;
...
statement_n;
RETURN expression;
END;
GO
The following tutorial exercise shows you how to create a simple user defined function:
USE FyiCenterData;
GO
CREATE FUNCTION Welcome()
RETURNS VARCHAR(40)
AS BEGIN
RETURN 'Welcome to FYIcenter.com';
END;
GO
PRINT dbo.Welcome();
GO
Welcome to FYIcenter.com
⇒ Using User Defined Functions in Expressions in SQL Server
⇐ Differences between Functions and Stored Procedures in SQL Server
2016-12-24, 2822🔥, 0💬
Popular Posts:
How To Break Query Output into Pages in MySQL? If you have a query that returns hundreds of rows, an...
How to download and install Microsoft .NET Framework Version 2.0 in SQL Server? .NET Framework Versi...
What is test testing area for? The testing area is provided to allow visitors to post testing commen...
How To Recover a Dropped Index in Oracle? If you have the recycle bin feature turned on, dropped ind...
How To Start Instance with a Minimal Initialization Parameter File in Oracle? The sample initializat...