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
Solved

View & Procedure - SQL Server

Posted on 2013-01-06
3
314 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
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

789 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