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, 2524🔥, 0💬
Popular Posts:
Where Is the Export Dump File Located in Oracle? If you are not specifying the dump directory and fi...
How to set database to be READ_ONLY in SQL Server? Databases in SQL Server have two update options: ...
How to set the current database in SQL Server? Once you are connected to the SQL Server, you should ...
How To Create a Stored Program Unit in Oracle? If you want to create a stored program unit, you can ...
How Fixed Length Strings Are Truncated and Padded in SQL Server Transact-SQL? When the length of the...