views:

161

answers:

1

I have a table-value function that works correctly if I try the following query:

SELECT    *
FROM    dbo.GetScheduleForEmployee() AS schedule

However if I try to create a view with that query I get a "too few parameters" error.

Is there a limitation with table-value functions and views?

+2  A: 

This works for me:

CREATE FUNCTION dbo.GetScheduleForEmployee()
RETURNS TABLE
AS
        RETURN
        (
        SELECT  1 AS id
        UNION ALL
        SELECT  2
        )
GO

CREATE VIEW myview
AS
SELECT  *
FROM    GetScheduleForEmployee() AS schedule

GO

SELECT  *
FROM    myview
Quassnoi
i just realized that the problem only happens when using the query designer to create the view
Hugo Zapata
If you are using MySQL you should take note that query designer will only execute the first line/statement of whatever you put in there.
rlb.usa
Thanks rlb.usa i'm using SQL Server (as specified in title and question tags),
Hugo Zapata