Solved

Performance Procedure

Posted on 2013-01-26
6
234 Views
Last Modified: 2013-01-27
I can win performance on sql server stored procedure. I need use cursor with fast_forward or while @@rowcount>0 i improve most performance?
0
Comment
Question by:fsouza
[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
6 Comments
 
LVL 39

Expert Comment

by:Aaron Tomosky
ID: 38823126
A cursor is usually the slowest way to do anything. Can you please post what you are trying to do?
0
 
LVL 5

Expert Comment

by:RehanYousaf
ID: 38823306
It depends on the situation ... I mostly try to avoid both ... If you explain what you want maybe we can help

P.S. Performance matters if you dealing with large amounts of data
0
 
LVL 6

Accepted Solution

by:
esolve earned 250 total points
ID: 38823540
0
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 

Author Comment

by:fsouza
ID: 38824177
The correct use is CURSOR LOCAL FAST_FORWARD or CURSOR FAST_FORWARD ???
0
 
LVL 5

Expert Comment

by:RehanYousaf
ID: 38824313
correct use is to avoid both ... atleast read those articles before asking same question again...
it all depends on your scenario which you havent told us yet :-)
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 250 total points
ID: 38824321
The correct use is CURSOR LOCAL FAST_FORWARD or CURSOR FAST_FORWARD ???
If I understand you correctly the question is:

What is the difference between using the keyword LOCAL and not using it?

The answer is nothing.  They are the same.

Here is the definition from SQL Server's BOL (my emphasis):
LOCAL
Specifies that the scope of the cursor is local to the batch, stored procedure, or trigger in which the cursor was created. The cursor name is only valid within this scope. The cursor can be referenced by local cursor variables in the batch, stored procedure, or trigger, or a stored procedure OUTPUT parameter. An OUTPUT parameter is used to pass the local cursor back to the calling batch, stored procedure, or trigger, which can assign the parameter to a cursor variable to reference the cursor after the stored procedure terminates. The cursor is implicitly deallocated when the batch, stored procedure, or trigger terminates, unless the cursor was passed back in an OUTPUT parameter. If it is passed back in an OUTPUT parameter, the cursor is deallocated when the last variable referencing it is deallocated or goes out of scope.

GLOBAL
Specifies that the scope of the cursor is global to the connection. The cursor name can be referenced in any stored procedure or batch executed by the connection. The cursor is only implicitly deallocated at disconnect.

Note:  
If neither GLOBAL or LOCAL is specified, the default is controlled by the setting of the default to local cursor database option. In SQL Server version 7.0, this option defaults to FALSE to match earlier  
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

734 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