Running script without having permission to Function

  • Good Morning.

    I have a T-SQL Script which has been developed to execute a Function1 (which itself calls another Function2). Unfortunately I do not have permission to execute these functions. Hence I am trying to re-write the Script to enable the core logic of these functions to be incorporated in to it.

    1. Function1 takes TWO parameters, and returns a Table

    CREATE FUNCTION [dbo].[Function1] (@Param1 int, @Param2 varchar)

    RETURNS TABLE

    AS

    RETURN

    (

    WITH CTE_O AS

    (SELECT F1 AS Field_O

    FROM Table1

    WHERE ODGUID = @Param1

    )

    SELECT *

    FROM dbo.Function2 (@Param1, @Param2, (SELECT TOP (1) Field_O FROM CTE_O) )

    );

     

    2) Function2 takes THREE parameters (two of which are exactly the same two parameters required by Function1). Function2 returns a Table which it passes back to Function1:

    CREATE FUNCTION [dbo].[Function2]

    (

    @Param1 int,

    @Param2 varchar,

    @Field1 int

    )

    RETURNS TABLE

    AS

    RETURN

     

    Kindly advise on a suitable structure to implement these two functions within my current Script.

    • This topic was modified 15 seconds ago by Reh23.

Viewing post 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply