The following example creates a function that compares two numbers and returns the larger value. For more information, see CREATE FUNCTION. create function f_sql_greater (float, float) returns float stable as $$ select case when $1 > $2 then $1 else $2 end $$ language sql; The follow...
Example of a CLR scalar-valued function Related content Applies to: SQL Server A scalar-valued function (SVF) returns a single value, such as a string, integer, or bit value. You can create scalar-valued user-defined functions in managed code using any .NET Fr...
Scalar function examples Table-valued function examples Show 2 more Applies to: SQL Server Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics Analytics Platform System (PDW) This article describes how to create a user-defined function (UDF) in SQL Server by using Transact-SQL....
You can use ODBC Scalar Functions in Transact-SQL statements. These statements are interpreted by SQL Server. They can be used in stored procedures and user-defined functions. These include string, numeric, time, date, interval, and system functions. Usage syntaxsql Copy SELECT {fn <function_...
You can useODBC Scalar Functionsin Transact-SQL statements. These statements are interpreted by SQL Server. They can be used in stored procedures and user-defined functions. These include string, numeric, time, date, interval, and system functions. ...
Syntax for Transact-SQL scalar functions. syntaxsql 复制 CREATE [ OR ALTER ] FUNCTION [ schema_name. ] function_name ( [ { @parameter_name [ AS ] [ type_schema_name. ] parameter_data_type [ NULL ] [ = default ] [ READONLY ] } [ , ...n ] ] ) RETURNS return_data_type [ ...
Scalar Functions CREATE FUNCTION [ schema_name. ] function_name ( [ { @parameter_name [ AS ][ type_schema_name. ] parameter_data_type [ = default ] } [ ,...n ] ] ) RETURNS return_data_type [ WITH <function_option> [ ,...n ] ] ...
As the name suggests: table-valued returns table, however Scalar-valued returns a single value, such as a string, integer, or bit value. 1、table-valued function As to create table-valued function, there are 2 ways, look at the example below please, it’s suitable for simple logic: ...
Scalar Function Information The following values of the InfoType argument return information about the scalar functions supported by the data source and the driver. For more information about scalar functions, see Appendix E: Scalar Functions. SQL_CONVERT_FUNCTIONS SQL_NUMERIC_FUNCTIONS SQL_STRING_FUNCTI...
Aggregate functions and scalar subqueries are permitted. Return types Returns the data type with the highest precedence from the set of types passed to the function. For more information, see Data Type Precedence (Transact-SQL). If all arguments have the same data type and the type is ...