How function will get execute internally in sql server?

  • HI All ,

    Can any one please explain me how function will get execute internally in sql server?

    With Thanks and regards,

    Ravindranath.S

  • Much the same way as a stored procedure or ad-hoc SQL batch.

    What exactly are you looking for?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Actually my sql statment like this

    SELECT DISTINCT UPP.ProductID,dbo.fnGetProductTestStatus(UPP.ProductID,@UserID) AS EndDate ,

    FROM #UserProductProgression UPP

    when i say like that how internally it execute inside the server .

    IS that a good practice to use function like that ?

    Performance wise any impact ?

  • IS that a good practice to use function like that ?

    Performance wise any impact ?

    You will have a performance impact. This is explained well here (including details on how this gets executed internally) -> http://sqlblog.com/blogs/adam_machanic/archive/2006/08/04/scalar-functions-inlining-and-performance-an-entertaining-title-for-a-boring-post.aspx

  • Thank you very much

  • ravindranath.s (9/7/2011)


    Actually my sql statment like this

    SELECT DISTINCT UPP.ProductID,dbo.fnGetProductTestStatus(UPP.ProductID,@UserID) AS EndDate ,

    FROM #UserProductProgression UPP

    when i say like that how internally it execute inside the server .

    IS that a good practice to use function like that ?

    Performance wise any impact ?

    It really depends on what that function is doing and how well it's written the degree to which it will impact performance.

    Have you looked at the execution plan for the query? That's part of how you can tell what's happening inside the system.

    ----------------------------------------------------The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore RooseveltThe Scary DBAAuthor of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd EditionProduct Evangelist for Red Gate Software

Viewing 6 posts - 1 through 5 (of 5 total)

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