Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Difference between Stored Procs and UDFs
Message
De
08/09/2014 10:35:18
 
 
À
08/09/2014 10:22:11
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2014
Application:
Web
Divers
Thread ID:
01607164
Message ID:
01607167
Vues:
70
This message has been marked as the solution to the initial question of the thread.
>I'm compiling some training resources for a new hire, and I need to come up with a decent list of differences between Stored Procs and UDFs in SQL Server and why you should use which.
>
>Here's what I have off the top of my head:
>
>A UDF is more easily joined into another query.
>A UDF cannot update data, only retrieve.
>
>I thought I had more. Help me out, folks.

Like Mike said, scalar UDFs can really impact performance in a bad way.

Yes, a UDF cannot update, only retrieve.

On using a UDF to join to another query...."sort of". You can have a table-valued function and use it like a derived table. When you want to apply individual rows from a TVF to other tables, you actually have to use CROSS APPLY. Not saying you were incorrect, just qualifying the concept.

Table valued functions also serve another great role - since views cannot receive parameters, people use views along with TVFs as a security feature (for access to rows)

Stored procs are for insert/update/deletes, or for bringing back full result sets. You can't use a stored proc to directly join (or apply) with other tables - not without redirecting to a temp table first.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform