May 26, 2026 at 10:47 am
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.
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.
May 27, 2026 at 2:20 pm
Thanks for posting your issue and hopefully someone will answer soon.
This is an automated bump to increase visibility of your question.
May 27, 2026 at 5:06 pm
without knowing the code of Function2 we can't help there. it may or not be possible/easy - but if function2 returns more than 1 row (first 1 returns a single row to pass to function2) then it may be tricker.
BUT.. if you have access to read the data on that database, then you should also be granted access to select/execute functions. Ask your admin for it.
June 2, 2026 at 5:01 pm
It's not completely clear what you want to do here. What is your script and what do you want returned? Are you trying to re-implement two functions you can't execute?
As Frederico noted, you need access to get the code of function2, but also, you should think about how to better explain what you want to have happen.
June 3, 2026 at 6:26 pm
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.
That's the whole key here. Whoever setup the second function either deliberately limited who run the function (possibly due to the sensitivity of the data it returns) or did so accidentally.
You need to get with the DBA and/or the people that own the function and get the necessary privs.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply