Additional SQL Server features and topics not covered by specific categories
I'm not sure that I understand your question. In your function definition you insert any data to a table, but you can do that when you use the function.
Here is an example of an inline table-valued function:
CREATE FUNCTION dbo.inline(@n int) RETURNS TABLE AS
RETURN (SELECT object_id, name FROM sys.objects WHERE object_id % @n = 0)
Here is the same function as a multi-statement function:
CREATE FUNCTION dbo.multistmt(@n int)
RETURNS @t TABLE (object_id int NOT NULL,
name sysname NOT NULL) AS
BEGIN
INSERT @t(object_id, name)
SELECT object_id, name FROM sys.objects WHERE object_id % @n = 0
RETURN
END
Here are examples of calling them and inserting data into a table:
CREATE TABLE #test (object_id int NOT NULL,
name sysname NOT NULL)
go
INSERT #test (object_id, name)
SELECT object_id, name FROM dbo.inline(5)
INSERT #test (object_id, name)
SELECT object_id, name FROM dbo.multistmt(7)