开发者

Need Multiple WITH statements in SQL UDF

开发者 https://www.devze.com 2023-03-04 17:48 出处:网络
I\'ve got a SQL UDF that I need to define both WITH SCHEMABINDING and WITH EXECUTE AS OWNER on.I\'ve tried a number of combinations including listing the WITH keyword twice, trying various methods of

I've got a SQL UDF that I need to define both WITH SCHEMABINDING and WITH EXECUTE AS OWNER on. I've tried a number of combinations including listing the WITH keyword twice, trying various methods of concatenation or operators, etc, and haven't had a lot of luck.

Can anybody help me with how to define multiple WITH statements in a single UDF

    CREATE FUNCTION [dbo].[Func_PullFolderIdsForUser](@companyId [int], @userId [int])
    RETURNS @folders TABLE (
        [FolderID] [int] NULL,
    ) WITH SCHEMABINDING 
    AS 开发者_Go百科
    BEGIN


Comma delimit them. e.g.

CREATE FUNCTION [dbo].[Func_PullFolderIdsForUser](@companyId [INT], @userId [INT])
    RETURNS @folders TABLE (
        [FolderID] [INT] NULL
    ) WITH SCHEMABINDING, EXECUTE AS SELF
    AS 
    BEGIN
    INSERT INTO @folders VALUES(1)
    RETURN
    END
0

精彩评论

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