Have you read any books on the subject? What particularly areas are you uncomfortable with?
Stored procedures (SPROCS) are just that, procedures that are stored. They are typically collections 1 or more regular T-SQL queries logically grouped together to perform some action. Often they are nothing more then a procedure of a single query operation.
One of the key points about SPROCS is that they are pre-optimized. When I call the database server and ask for this: "SELECT * FROM MyTable", the server has to first compute how to best execute this query. This is referred to the "execution plan". When you put this query (as simple as it is) into a SPROC, when you insert the SPROC into the database, the DB engine "compiles" it and stores it and the execution plans for all the queries in it. This makes the execution of the query faster each time, which could save lots of cycles.
Another key point of using SPROCS is the ability to make all or parts of the group of queries contained in it transactional. What this means is that you could execute several different (but related) queries in sequence and if you detect that one of them fails you can roll back the entire set of queries, leaving your data as it was before you started the transaction. This is a very powerful tool when you have complex procedures that touch many tables. Non-transactional sequences of related queries with a mid-execution failure can lead to orphan records. (An important note: with MS-SQL, any single query is executed in a single transaction. If you execute a stored procedure, the whole thing will execute as a single transaction. However, you can certainly explicitly define transactions inside a SPROC so that you can commit them as you go.)
As far as SPROC parameters go, it's much like functions in any program code. A SPROC can have parameters in several flavors:
Input only: pass a value into a SPROC
Output only: sets a value inside the SPROC for use after you call it
Input/Output: pass in and/or retrieve a value
Return: a special return value set inside the SPROC with "RETURN(x)". This can be any DB data type. In MS-SQL this parameter is always named @RETURN.
SPROCS can return 1 or more result sets. SELECT queries inside a SPROC will return result sets. These would be consumed in your .NET code.
Hopefully this has helped a bit. Feel free to ask more specific questions.
-
Peter