SQLTeam.com | Weblogs | Forums

Fixing / updating non-contra rows

I need to create a one-off datafix script that identifies rows of financial data that are not part of a double-entry pairing i.e. have no contra row. I have a unique key for each row, a key for each logical group of pairings and also a sequence number that follows sequentially in a pairing e.g. Accounting Entry row = Sequence No.1 / Contra row = Sequence No.2 and so on. However, Sequence nos can repeat further down the chain if there is an INSERT rather than an UPDATE.
So basically I need to create a negative entry for any row that has no contra, with a corresponding pairing Sequence No (+1) that does not clash with an existing Sequence No.
Can anyone help? Can send additional info if required. Thanks.

Welcome,

would b e better if you can give us sample data as follows

declare @incense table(id int, name varchar(50))

insert into @incense
select 1, 'Frank'

1 Like

screenshot attached with sample data

Turn that image into real ddl and dml

declare @incense table(id int, name varchar(50))

insert into @incense
select 1, 'Frank'

Help us help you

1 Like

I agree. We can't write code against a screen shot.

Please understand that we may help many people in one day. We just don't have time to transcribe everyone's pictures into directly usable data.

2 Likes