Archive for March 13, 2008

Views and Stored procedures

To quickly understand what the views and stored procedures in Sql server are, pls read the below two sql sentence:

SELECT * FROM [Category Sales For 1997]

Exec getpassword ‘domain’,'alias’

First sql query is using views, it is slightly different from normal query sentence, which may look like: select * from categorytablename where salesdate=1997

Second query is very strange, but this is exactly using a stored procedures to get password for the account ”domain\alias”, the normal query sentence may look like: select password from passwordtablename where a/cdom = ‘domain’ and a/calias = ‘alias’

Important different between them is view doesn’t accept parameters, but stored procedures does. Their similarity is that a view returns a result set, and a stored procedure can also return one.

Comments