Get the App
SLTechnology News&Howtos  ›  Database  › 

SQL table-valued function

Shulou Source: shulou.com Published: 2022-06-01 18:39:59 11月04日 Update

1. Multi-statement table-valued function

-- =-- Author:-- Create date:-- Description:-- = CREATE FUNCTION table-valued function name (@ parameter 1, @ parameter 2) RETURNS TABLE AS RETURN (--data table SELECT * from table where field1= @ parameter 1 and field2=@ parameter 2) GO

2. Inline table-valued function

-- =-- Author:-- Create date:-- Description:-- = CREATE FUNCTION table-valued function name (@ parameter 1, @ parameter 2) RETURNS @ returns table TABLE (returns table field 1 field type, table field 2 field type, table field 3 field type.) AS BEGIN insert into @ return table select field3,field4,field5 from table where field1=@ pass parameter 1 and field2=@ pass parameter RETURN END GO

Tags: Parameters fields functions types statements data Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Apple Shulou Tech Info Docker OPPO Reno