我正在将FoxPro代码转换为SQL以生成报告。当前的FoxPro代码如下。我需要能够创建两个游标,在其中存储两个字段中的数据,并对照表检查它们以替换数据。谁能帮我将这段代码转换为sql server的sql吗?
CREATE Cursor delete_cursor(salesno c(6), release_number c(3))
SELECT table1
GOTO TOP
lcsono= table1.salesno
lcrelease = table1.release_number
GOTO 2
SCAN REST
IF table1.salesno == lcsono AND table1.release_number <> "000"
AND lcrelease = "000"
SELECT delete_cursor
APPEND BLANK
REPLACE table1.salesno WITH lcsono
REPLACE table1.release_number WITH lcrelease
SELECT table1
ENDIF
lcsono = table1.salesno
lcrelease= table1.release_number
ENDSCAN
SELECT delete_cursor
INDEX on ALLTRIM(delete_cursor.salesno) + ALLTRIM(delete_cursor.releaseno)
TAG tagdelete
SELECT table1
GOTO TOP
SCAN
IF SEEK(ALLTRIM(table1.salesno) + ALLTRIM (table1.salesno),
"delete_cursor", "tagdelete")
REPLACE table1.delflag WITH "Y"
ENDIF
ENDSCAN
DECLARE CURSOR @fsono char(6)
update table1.salesno Set
table1.salesno = @fsono
where
@fsono = table1.salesno
AND table1.release_number <> "000"
AND lcrelease = "000"
DECLARE CURSOR @release char(6)
update table1.release_number Set
table1.release_number = @release
where
@fsono = table1.salesno
AND table1.release_number <> "000"
AND @release = "000"