[thelist] Effcient ASP Script?

Scott pippen at bigpond.net.au
Mon Nov 25 17:04:01 CST 2002


As others have mentioned, there is no real need to do this processing
in VB - its best to do it at the database level, esp if no significant output
is to be returned.

You could wrap this code below in a stored proc or pass it as a string
to your connection object

CREATE PROCEDURE dbo.sp_BigUpdate @ARowsReturned int OUTPUT AS
BEGIN

  UPDATE Registrants
  SET
    Type = 1
  FROM
   (SELECT TOP 2000 Registrant.ID
    FROM Registrant
    WHERE [whatever]
    ORDER BY [whatever]) as SelectTable
  where
    Registrants.ID = SelectTable.ID

  select @ARowsReturned = @@Rowcount

END

If you don't want to or can't use a stored procedure, an update statement
followed by a "select count(*) from Registrants where ..." might return your
rows affected.

more info to add to the mass already provided but hth



----- Original Message -----
From: "Adam Slesinger" <badlanners at hotmail.com>
To: <thelist at lists.evolt.org>
Sent: Tuesday, November 26, 2002 6:45 AM
Subject: [thelist] Effcient ASP Script?


: Hi folks!
:
: I am writing a page that selects all records with company names and then
: updates the type of those records if they are the first 2000 records.  The
: database has a total of 13,000 records.  When I run this on my server, it
: takes a long time, and then times out.
:
: My 1st questions is, how can I keep any script in general from timing out?
:
: My 2nd question is - is my code efficient?  I wouldn't think that it would
: take so long for this process to run, but it only gets through about 1400
: records before the timeout happens.
:
: Any help is appreciated!
:
: Thanks,
: adam
:
: set conn = server.createObject("ADODB.Connection")
: conn.open Session("connection")
: set rstemp = server.createobject("ADODB.Recordset")
:
: SQL = "SELECT * FROM registrants WHERE company <> ''"
: rstemp.open SQL, conn
:
: do while not rstemp.eof
:     strCount= strCount+ 1
:
:     if strCount <= 2000 and strCount > 0 then
:         'Update Type
:         set typeUpdate= conn.execute("UPDATE registrants SET type= 1 WHERE
: company = '" & rstemp("company") & "'")
:     end if
:
: rstemp.moveNext
: loop
:
: conn.close
: set conn = nothing
: --
: * * Please support the community that supports you.  * *
: http://evolt.org/help_support_evolt/
:
: For unsubscribe and other options, including the Tip Harvester
: and archives of thelist go to: http://lists.evolt.org
: Workers of the Web, evolt !
:





More information about the thelist mailing list