我有一个SQL UDF,我需要定义WITH SCHEMABINDING和WITH EXECUTE AS OWNER。我尝试了很多组合,包括列出两次WITH关键字,尝试各种连接或运算符等方法,并且没有太多运气。
任何人都可以帮助我如何在单个UDF中定义多个WITH语句
CREATE FUNCTION [dbo].[Func_PullFolderIdsForUser](@companyId [int], @userId [int])
RETURNS @folders TABLE (
[FolderID] [int] NULL,
) WITH SCHEMABINDING
AS
BEGIN
答案 0 :(得分:3)
逗号分隔他们。 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