Re: Trying to avoid using a cursor....
From: David Portas (REMOVE_BEFORE_REPLYING_dportas_at_acm.org)
Date: 09/12/04
- Next message: Gert-Jan Strik: "Re: How to efficiently return the last order for all customers"
- Previous message: Narayana Vyas Kondreddi: "Re: Mandatory participation"
- In reply to: TomT: "Trying to avoid using a cursor...."
- Next in thread: TomT: "Re: Trying to avoid using a cursor...."
- Reply: TomT: "Re: Trying to avoid using a cursor...."
- Reply: Mark: "Re: Trying to avoid using a cursor...."
- Messages sorted by: [ date ] [ thread ]
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 --
- Next message: Gert-Jan Strik: "Re: How to efficiently return the last order for all customers"
- Previous message: Narayana Vyas Kondreddi: "Re: Mandatory participation"
- In reply to: TomT: "Trying to avoid using a cursor...."
- Next in thread: TomT: "Re: Trying to avoid using a cursor...."
- Reply: TomT: "Re: Trying to avoid using a cursor...."
- Reply: Mark: "Re: Trying to avoid using a cursor...."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|