Re: Trying to avoid using a cursor....

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: David Portas (REMOVE_BEFORE_REPLYING_dportas_at_acm.org)
Date: 09/12/04


Date: Sun, 12 Sep 2004 10:19:27 +0100


> I want
> to run an procedure that will take the value of that first record in
> column
> test, and place values in that column for each of the next 9 records,
> incremented by 1. I.e. row 2 would have 2 in the column, row 3, would have
> 3,
> and so on.

Why? If you want to add a row number then don't put it in the table,
calculate it when you query the data:

SELECT
  (SELECT COUNT(*)
   FROM Authors
   WHERE au_id <= A.au_id) AS row_num
  ,*
  FROM Authors AS A

Tables have no inherent ordering so your request doesn't make sense unless
you define in what order the numbers are to be allocated.

-- 
David Portas
SQL Server MVP
--


Relevant Pages

  • Re: Controlling Server-Affinity (Was Re: ajax - dynamic update)
    ... It could be anywhere from 0.00000001% of the request all the way up to 99.99999999999% of the request. ... Rather than make one request and try to determine when the first record is returned, simply make a request for the first record, when the first record is received, display it and then make a second request to the server for the rest of the request. ...
    (comp.lang.javascript)
  • INSERT INTO
    ... - I can import Excel data into Access using a request INSERT INTO ... .movefirst let me on the first record of what was just added with INSERT ... Dim cnn As New ADODB.Connection ...
    (microsoft.public.vb.general.discussion)
  • INSERT INTO
    ... - I can import Excel data into Access using a request INSERT INTO ... .movefirst let me on the first record of what was just added with INSERT ... Dim cnn As New ADODB.Connection ...
    (microsoft.public.data.odbc)
  • INSERT INTO
    ... - I can import Excel data into Access using a request INSERT INTO ... .movefirst let me on the first record of what was just added with INSERT ... Dim cnn As New ADODB.Connection ...
    (microsoft.public.data.odbc)
  • Re: Decrypt SQL Proc
    ... Do you have any other link that accomplishes the same ... request. ... >David Portas ... >SQL Server MVP ...
    (microsoft.public.sqlserver.programming)