| Author |
Topic |
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2006-11-30 : 05:30:01
|
| Hai fyi,can u please tell the main difrerence between stored procedure and view.which is the better option to choose. |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-11-30 : 05:34:23
|
| Do you have interview tommorrow?SP is basically used to do some kind of complex processing which is not possible using single query statement. Also, it gives advantage of performance due to cacheing of execution plan.The main use of view is to hide the complex joins/subqueries and the need to rewrite them each time. Also, it helps to hide the underlying table structure and give only what is required to the users depending on their roles.Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-30 : 05:37:55
|
| Thery only alike in one aspect. They can both return a resultset.A view is like a layer on a table, or several tables. In most cases, it is only possible to do a SELECT from the view. In some cases, it is even possible to UPDATE some records. I don't know how DELETE is treated. Never tried.A stored procedure is like a program. You can do almost anything with SQL, such as returning data, insert data, delete data, creating tables, logins and other views and stored procedures.Peter LarssonHelsingborg, Sweden |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-11-30 : 05:49:28
|
quote: You can do almost anything with SQL, creating....stored procedures.
Is that possible, Peter? I don't think you mean directly.Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-11-30 : 06:00:22
|
Don't even mention D-Sql!!I have seen so many sisastrous outcomes of it that I feel sick when I hear it. Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-30 : 06:03:58
|
When properly handled it can be a powerful tool.Think of all PIVOT routines there are! Here is one http://www.sqlservercentral.com/columnists/plarsson/pivottableformicrosoftsqlserver.aspI sometimes use D-SQL to bridge old legacy systems with modern normalized databases. Both we have seen enough with bad examples here at SQLTeam, right? To last a lifetime...A lifetime with laughter when shown on presentations as warning examples and so on! My audience still enjoyes them!Peter LarssonHelsingborg, Sweden |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-11-30 : 06:16:26
|
Yes, I know it's very powerful but most of the time, people tend to use the power in wrong ways. That's what I fear of !Can you believe I worked on the project where table names were passed between SPs and global temp tables ruled the scenario...it was a mess! Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-01 : 03:24:31
|
quote: Originally posted by sent_sara Hai fyi,can u please tell the main difrerence between stored procedure and view.which is the better option to choose.
1 Do google search2 Refer sql server help fileMadhivananFailing to plan is Planning to fail |
 |
|
|
|