The CREATE FUNCTION (SQL scalar, table, or row) statement is used to define a user-defined SQL scalar, table, or row function. A scalar function returns a single value each time it is invoked, and is generally valid wherever an SQL expression is valid. A table function can be used in...
This CREATE FUNCTION (SQL scalar) statement creates an SQL function at the current server. The function returns a single result. Invocation This statement can be embedded in an application program or issued interactively. It is an executable statement that can be dynamically prepared. ...
SQL 複製 -- Replace a SQL scalar function. > CREATE OR REPLACE FUNCTION square(x DOUBLE) RETURNS DOUBLE RETURN x * x; -- Replace a SQL table function. > CREATE OR REPLACE FUNCTION getemps(deptno INT) RETURNS TABLE (name STRING) RETURN SELECT name FROM employee e WHERE e...
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 [ ...
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 [ ...
Transact-SQL 語法慣例 語法 --Transact-SQL Scalar Function Syntax CREATE FUNCTION [ schema_name. ] function_name ( [ { @parameter_name [ AS ][ type_schema_name. ] parameter_data_type [ = default ] [ READONLY ] } [ ,...n ]
在MSTVF 中, function_body 是一系列的 Transact-SQL 語句,可填入 TABLE 傳回變數。scalar_expression指定純量函數傳回的純量值。TABLE指定資料表值函式 (TVF) 的傳回值是資料表。 只有常數和 @local_variables 才能傳遞給 TVF。在內嵌TVF中,傳 TABLE 回值是透過單 SELECT 一語句來定義。 ...
在标量函数中,function_body是一系列Transact-SQL语句,这些语句一起使用的计算结果为标量值。 在多语句表值函数中,function_body是一系列Transact-SQL语句,这些语句将填充TABLE返回变量。 scalar_expression 指定标量函数返回的标量值。 TABLE 指定表值函数的返回值为表。只有常量和@local_variables可以传递到表值函数。
In multistatement table-valued functions,function_bodyis a series of Transact-SQL statements that populate a TABLE return variable. scalar_expression Specifies the scalar value that the scalar function returns. TABLE Specifies that the return value of the table-valued function is a table. Only const...
Only a constant value, such as a character string; a scalar function (either a system, user-defined, or CLR function); or NULL can be used as a default. To maintain compatibility with earlier versions of SQL Server, a constraint name can be assigned to a DEFAULT. constant_expression A ...