Justin,
You can use either one, or you can use combination of both; create a view
and access it from a stored procedure. The best practice is to use Stored
Procedures for any data-related operation especailly in a web application.
Here's the definitions from SQL Server Book Online:
Stored Procedure:
A stored procedure is a group of Transact-SQL statements compiled into a
single execution plan.
View:
A view can be thought of as either a virtual table or a stored query. The
data accessible through a view is not stored in the database as a distinct
object. What is stored in the database is a SELECT statement. The result set
of the SELECT statement forms the virtual table returned by the view. A user
can use this virtual table by referencing the view name in Transact-SQL
statements the same way a table is referenced.
See books online for more information.
"Justin" wrote:
I am creating a web app for a client in VS.NET using ASP.NET with C#. I need
to query three tables in a database using one parameter and display the
results on the page. my question is should I use a Stored Procedure or view
in SQL Server to get the data from multiple tables? What is the difference?
and where can I find a some articles on write code to display the results of
the SP or view?
Thanks, Justin.