Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Difference between view and Stored Proceedures

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-03-12 : 09:38:16
John writes "Sql Server 2000 sp2 on Windows 2000

I am new to Sql server and use Access adp to manage tbls, querys etc. I have created many views that pull data from various tables together and the retrieve the information via a connection on my ASP page. "select * from view where OrderID=" & Request("OrderID")

I have seen examples of stored proceedures to this with input parameters. Create a stored proceedure using same sql as view but use @ for parameters then call it via connection

conn.execute("storedproceedurename " & parameter)

Both seem to work so my question finally is, what is the difference between using views and stored prodeedures for extracting data to be displayed in ASP?

Many thanks

John"

joldham
Wiseass Yak Posting Master

300 Posts

Posted - 2002-03-12 : 10:34:12
Views allow you to see a subset of data, for instance if you have 50 departments in a store, you could set up a view to show only department 20. If the view is a simple view (such as a subset of only one table), then you can update, delete, and insert rows into the view (table).

A Stored Procedure allows you to specify input parameters, as well as do a little bit of Procedural Programing, hence the term procedure. If for instance, you wanted to several values, all which update several different tables, then you would use a stored procedure to accept the values as input parameters, and use the stored procedure to create the updates for each individual table.

I am sure there is a lot more to stored procedures and I would suggest reading more in the BOL.

Jeremy



Go to Top of Page
   

- Advertisement -