开发者

Using a table-value function inside a view in SQL Server

开发者 https://www.devze.com 2022-12-31 06:14 出处:网络
I have a table-value function that works correctly if I try the following query: SELECT* FROMdbo.GetScheduleForEmployee() AS schedule

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 paramet开发者_C百科ers" error.

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


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
0

精彩评论

暂无评论...
验证码 换一张
取 消