Stored procedure or view?

G

Guest

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.
 
G

Guest

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.
 
P

Phil

From what you've said, I would go with a stored procedure (try a search for
<italics>microsoft data access block</italics>). To actually display the
results - www.asp.net has some pointers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top