I wonder if I can run the following procedure in SQLite:
set nocount on
select T.ID, max(T.SerialNo) as SerialNo
into
from Ticket as T, Ticket as inserted
where t.ID = inserted.ID
group by T.id having count(*) > 1
declare zeiger cursor for
select SerialNo
from
declare @SerialNo int
OPEN Zeiger
FETCH NEXT FROM zeiger INTO @SerialNo
WHILE (@@fetch_status <> -1)
BEGIN
IF (@@fetch_status <> -2)
BEGIN
update T
set ID = (select max(id) + 1 from Ticket)
from ticket AS T,
where t.serialNo = i.serialno
and I.Serialno = @SerialNo
END
FETCH NEXT FROM zeiger INTO @SerialNo
END
CLOSE Zeiger
DEALLOCATE Zeiger
DROP TABLE
This is a small procedure from ms-sql2000 that clears Ticket_id doubling in this table. Ticket of the following structur:
create table Ticket (serialNo int identity(1,1) not null
, ID as int not null
, Ticket_issue as varchar(50)
, some_more_field varchar(500))
Due to a simple merge from different databases, ticket_id is not unique. To fix it by renumbering this, I developed this procedure, but now we have a similar problem on SQLite-db.
source
share