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

拈花ヽ惹草 提交于 2019-12-21 05:21:57

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/2877247/using-a-table-value-function-inside-a-view-in-sql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!