Re: Cursor vs. table data type

From: Tom Moreau (tom_at_dont.spam.me.cips.ca)
Date: 07/08/04


Date: Thu, 8 Jul 2004 09:07:58 -0400

Cursors are extremely slow. What exactly do you need to do? Are you
looking to insert rows into a table that don't already exist?

-- 
Tom
---------------------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"dw" <cougarmana_NOSPAM@uncw.edu> wrote in message
news:u7e6LgOZEHA.2844@TK2MSFTNGP12.phx.gbl...
Hello, all. We need to loop through the values in one table and compare them
with values in another. Which is more efficient -- a cursor or a table data
type for the first table? For example, this is the sort of query we run,
-- from the cursor on the 1st table, we get @strCourseSection and
@strSemester
Select @intInstPIDM = a.instPIDM From dbo.tblCourseSect a
    Where a.courseSection = @strCourseSection and a.semester = @strSemester
  If (@intInstPIDM Is Not Null) Begin ........
    -- do an insert/update on second table here
Thanks.


Relevant Pages

  • Re: Cursors in functions
    ... >> When I want to loop through a result in sp I use Cursor ... >Server are extremely slow. ... >statements can be slow by itself, since SQL Server has to ... >may be able to offer a set-based solution. ...
    (microsoft.public.sqlserver.programming)
  • Re: Error adding command properties for stored procedure call
    ... I see you are using the SQL Native Client for SQL Server ... A server cursor is not allowed on a remote stored procedure or stored ... The stored procedure called is a test one that simply SELECTs the name field ... int InitializeAndConnect; ...
    (microsoft.public.data.oledb)
  • Re: C5 woes. How stable is VFP really?
    ... After that I close the SQL server cursor and work with my manual cursor instead. ... a VFP9 app on a really old machine ... app was under more "pressure", VFP showed ...
    (microsoft.public.fox.programmer.exchange)
  • Re: SQL HELP PLEASE!! Cursor only returns part of the data
    ... First of all, it's not the cursor as such that is bad, it is the looping. ... and re-writing it to handle set-based data will cost you more ... set-based solution do not perform well, ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ...
    (comp.databases.ms-sqlserver)
  • Re: Using Cursors
    ... it seems I've stirred up a hornet's nest with my cursor question. ... finding the discussion valuable in my circumstances (moving from Oracle to ... SQL Server). ... > DECLARE curEpisode SCROLL CURSOR FOR ...
    (microsoft.public.sqlserver.programming)