Tmn2 tanya donk,

kalo msl saya punya data spt di bwh ini di db.
id     item#
s1    0001
s1    0002
s2    0001
s2     0002
gimana querynya supaya dptin hsl spt ini, jd field no
itu tambahan dr kitanya.
no    id    item#
1    s1    0001
2    s1    0002
1    s2    0001
2    s2    0002


Saya uda sempet dpt jwban dr tmn  tp dia pake strore procedure dgn ada 
keyword cursor2 gitu.
ini aku copy:
--
declare @resulttable table(nomor int,
id varchar(50), itemcode varchar(100))

declare @No_Trx as int
declare @id as varchar(50)
declare @itemcode as varchar(100)

set @No_Trx = 0

insert into @resulttable
select 0, id, description FROM table1

DECLARE Action_cursor CURSOR FOR
SELECT nomor, id, itemcode FROM @resulttable
OPEN Action_cursor
FETCH NEXT FROM Action_cursor INTO @No_Trx, @id, @itemcode
WHILE @@FETCH_STATUS = 0
BEGIN
set @No_Trx = @No_Trx + 1

update @resulttable
SET nomor = @No_Trx
WHERE id = @id
FETCH NEXT FROM Action_cursor INTO @No_Trx, @id, @itemcode

END
CLOSE Action_cursor
DEALLOCATE Action_cursor


select * FROm @resulttable
--
Kira2 ada ga ya query yg lbh simple yg tanpa kursor2 gitu??

Thank in advance,
Sylvi.
-- 
Hope sees the invisible,
feels the intangible,
and achieves the impossible.







-- 
www.ITCENTER.or.id - Komunitas Teknologi Informasi Indonesia 
Info, Gabung, Keluar, Mode Kirim : [EMAIL PROTECTED] 
::: Hapus bagian yang tidak perlu (footer, dst) saat reply! ::: 
## Forum: ITCENTER.or.id/forum ## Jobs: ITCENTER.or.id/jobs ## 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ITCENTER/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Kirim email ke