question

ashok2012 avatar image
ashok2012 asked

If multiple UDF are used in SQL then logically which UDF will perform first and which next

If multiple functions are used in the code, then logically which will perform first and which next. If we use two UDF's Generally Can you tell me Which UDF's are Perform first? Sample: UDF1: CREATE FUNCTION dbo.UDF1( @Parameter1 INT ) RETURNS Table AS RETURN ( SELECT * from dbo.Table1 A join dbo.Table2 B on A.id= b.id join dbo.Table3 c on A.id= C.id Where A.id=@Parameter1 ) END UDF2: CREATE FUNCTION dbo.UDF2( @Parameter2 INT ) RETURNS INT AS BEGIN RETURN ( SELECT Count(*) from dbo.UDF1(@Parameter2) ) END Result: Declare @Parameter2 int set @Parameter2=5 SELECT dbo.UDF2(@Parameter2) as UDFexecution if we execute UDF2 Can you tell me which UDF execute first?
udf
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Is that code going to be executed against a large number of rows?
0 Likes 0 ·

1 Answer

·
David Wimbush avatar image
David Wimbush answered
Surely UDF2 will start, then UDF1 will start and end, and then UDF2 will end.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.