Answers for "Multi_Statement Table-Valued Function"

SQL
1

Multi_Statement Table-Valued Function

CREATE FUNCTION udfContacts()
    RETURNS @contacts TABLE (
        first_name VARCHAR(50),
        last_name VARCHAR(50),
        email VARCHAR(255),
        phone VARCHAR(25),
        contact_type VARCHAR(20)
    )
AS
BEGIN
    INSERT INTO @contacts
    SELECT 
        first_name, 
        last_name, 
        email, 
        phone,
        'Staff'
    FROM
        sales.staffs;

    INSERT INTO @contacts
    SELECT 
        first_name, 
        last_name, 
        email, 
        phone,
        'Customer'
    FROM
        sales.customers;
    RETURN;
END;
Code language: SQL (Structured Query Language) (sql)
Posted by: Guest on October-21-2021

Code answers related to "Multi_Statement Table-Valued Function"

Code answers related to "SQL"

Browse Popular Code Answers by Language