Solved

View & Procedure - SQL Server

Posted on 2013-01-06
3
316 Views
Last Modified: 2013-01-06
Hello All,

I cant help but ask this question to all SQL Gurus here.

Recently I created a VBA application that calls a complex set of sql statements to show a data set in a certain way.
In order to accomplish the above, I tried doing it in two different ways...

1)I created a stored procedure to do the above
2)I also created a View to do the above.

I was tracking the seconds in the VBA application in terms of the time it takes to complete the command.

I found some real interesting info:

When VBA called the view from SQL Server, it took near to 1 minute
when VBA called the stored procedure from SQL Server it took 30 seconds

Why is this amazing difference ?

Is the stored procedure is better off than view in certain cases?
What are the advantages of using StoredProcedure ? Why would you want one, performance wise? like whats the real 'physics' behind it, that makes it preferable...if you get what I am saying..

Thanks
R
0
Comment
Question by:Rayne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 300 total points
ID: 38749173
Why is this amazing difference ?
A well-coded Stored Procedure will always outperform a VIEW.  This is especially true after the plan is cached.  In other words, you execute it a second time and the Stored Procedure plan is still in memory.

Is the stored procedure is better off than view in certain cases?
See above.

What are the advantages of using StoredProcedure ?
Performance and security.
0
 
LVL 8

Assisted Solution

by:Crashman
Crashman earned 200 total points
ID: 38749215
Take a look,


SQL SERVER – The Limitations of the Views – Eleven and more…

SQL Server Journey with SQL Authority
0
 

Author Closing Comment

by:Rayne
ID: 38749451
Awesome Guys, hats off to you!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how the fundamental information of how to create a table.

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question