what's faster? retrieving data via a stored procedure or function

  • I need to get the credentials of staff in my database as one value. Problem is they can have more than one credential record. What is the best way to retrieve this data - via a stored procedure and have the credential as my output or via a function? I'm not seeing a real difference in my database.

  • You mean a user defined function in TSQL? That's just another way of writing a query (assuming we're not talking table valued user defined functions). There isn't, per se, a difference between calling a function and calling a query.

    The way to tell if there's a difference is to look at the execution plans, the execution time, and the scans and reads. Then you can determine which is the better approach.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 2 posts - 1 through 1 (of 1 total)

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