-- Query with the table-valued function SELECT * FROM dbo.GetActiveUsers();
INSERT INTO Users (Username, Email) VALUES (@Username, @Email);
-- Create a useful function CREATE FUNCTION dbo.GetActiveUsers() RETURNS TABLE AS RETURN ( SELECT UserID, Username, Email, CreatedDate FROM Users WHERE IsActive = 1 ); GO