When should I use a function rather than a stored procedure in SQL, and vice versa? What is the purpose of each?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Functions are computed values and cannot perform permanent environmental changes to
SQL Server(i.e., noINSERTorUPDATEstatements allowed).A function can be used inline in
SQLstatements if it returns a scalar value or can be joined upon if it returns a result set.A point worth noting from comments, which summarize the answer. Thanks to @Sean K Anderson: