🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: bit.databases.mssql-l
Article #249

Need help please

#249
From: no name
Date: Wed, 24 Nov 1999 00:00
28 lines
1453 bytes
I am trying to update a new column called "sorting", with incremented values
strating at 1, before doing that I need the table to be sorted using three
columns.  I am using a cursor but it is not working I need your help.
Thanks in advance:

CODE:

set @ordering_count=0
declare review_test_cursor cursor  scroll keyset for

select oid,decision_date,ranking,sorting,decision_id
from DECISION_FLAGS
order by oid,decision_date,ranking asc

open review_test_cursor
fetch next from review_test_cursor

while (@@fetch_status = 0 )
Begin
 update DECISION_FLAGS
             set sorting    = CAST ((@ordering_count + 1)  as VARCHAR)
             set @ordering_count    = @ordering_count   + 1

fetch next from review_test_cursor
end

close review_test_cursor
deallocate  review_test_cursor
Technical Details
Message-ID: <gVY_3.4454$V4.160891@news1.rdc1.on.wave.home.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f6611,517c60d727b2908f,start
X-Google-Attributes: gidf6611,public
From: "no name" <noname@earth.com>
Subject: Need help please
Date: 1999/11/24
Message-ID: <gVY_3.4454$V4.160891@news1.rdc1.on.wave.home.com>
X-Deja-AN: 552675418
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
X-Complaints-To: abuse@home.net
X-Trace: news1.rdc1.on.wave.home.com 943479500 24.112.130.107 (Wed, 24 Nov 1999 13:38:20 PST)
Organization: @Home Network Canada
X-MSMail-Priority: Normal
NNTP-Posting-Date: Wed, 24 Nov 1999 13:38:20 PST
Newsgroups: bit.databases.mssql-l