Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases

Harsh s
PLUS
Harsh s
Courses Plus Student 30 Points

difference between store procedure and function

can you please let me know what is the difference between the function and store procedure and why we need to pass parameters in them

2 Answers

Steven Parker
Steven Parker
231,128 Points

A function must take at least one parameter, and it must return a value. With a stored procedure both parameters and return values are optional.

You might want to think of a function as something that "takes an input, does something with it, and then gives something back"; where a stored procedure is just any collection of statements that can be executed as a group.

Kevin Gates
Kevin Gates
15,053 Points

While this is not a Treehouse Course, I took this PluralSight course on Stored Procedures and it is very good. I've found it to be fun, but also educational. I have a coworker who is very knowledgeable about stored procedures and this course is covering even the "gotchas" that he mentioned. Start here if you want to learn them, at least until Treehouse adds some courses: https://www.pluralsight.com/courses/sql-server-database-programming-stored-procedures