Question

I have three rows in the database out of those two are identical. Out of those two same rows I have to make changes in one using the sybase.Ex.

Row1: ABC 456 ancient block
Row2: ABC 456 ancient block
Row3: DEF 678 class   block

I have to make changes in one of the first two block by changing ABC to XYZ.If there are only two identical blocks then I am doing the below method.

begin transaction AA
set rowcount 1
update table 
set col1 = XYZ
where col1 = ABC
commit transaction AA
set rowcount 0

It is easy if there are two identical rows but if two identical and one different then sybase picks the unique row and updates it. Can someone tell how to solve this three rows problem ? I am using aseisql for the Sybase.

Was it helpful?

Solution

Have you tried:

update top 1 table 
set col1 = XYZ
where col1 = ABC

OTHER TIPS

This is the solution I figured.

begin transaction a
set rowcount 2
update table 
set col1 = XYZ
where col4 = block

commit transaction a
set rowcount 0

It will update one of the duplicate rows and the unique row. Then I will update the unique row to its original value separately using the update statement. I know its sound crude but no one has answered satisfactorily.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top