Q:

How to insert into a table with no writable columns in SQL Server 2005?

Specifically I have a function with the following signature:
CREATE FUNCTION [dbo].[GetLevelData]()
RETURNS @level TABLE (
    [Level]                 INT PRIMARY KEY IDENTITY,
    [Source Column Name]    AS '{Option Level ' + CAST([Level] AS VARCHAR(10)) + '}',
    [Parent Column Name]    AS '[Parent_L' + CAST([Level] AS VARCHAR(10)) + '_Option]'
)

How can I insert rows into it without modifying the definition of the table?

A:

Within the body of the function definition, use
INSERT @level DEFAULT VALUES;

to create a new row in the to-be-returned table.
To do a number of rows at once, you can do this:
CREATE FUNCTION [dbo].[GetLevelData]()
RETURNS @level TABLE (
    [Level]                 INT PRIMARY KEY IDENTITY,
    [Source Column Name]    AS '{Option Level ' + CAST([Level] AS VARCHAR(10)) + '}',
    [Parent Column Name]    AS '[Parent_L' + CAST([Level] AS VARCHAR(10)) + '_Option]'
)
AS
BEGIN
    WHILE ISNULL(SCOPE_IDENTITY(), 0) < 5    -- to end up with 5 rows
        INSERT @level DEFAULT VALUES

    RETURN
END

which is a bit sneaky but does work

