Kod boniteta dupli kljucevi
declare @nesto char (15)
declare aPoz cursor local fast_forward for
select acKey
from _LogClient
group by acKey
having count(*) = 2
open aPoz
fetch from aPoz into @nesto
while @@fetch_status = 0
begin
delete top (1) from _LogClient where acKey = @nesto
fetch from aPoz into @nesto
end
close aPoz
deallocate aPoz
declare xPoz cursor local fast_forward for
select acKey
from _LogClient
group by acKey
having count(*) = 2
open xPoz
fetch from xPoz into @nesto
while @@fetch_status = 0
begin
delete top (1) from _LogClient where acKey = @nesto
fetch from xPoz into @nesto
end
close xPoz
deallocate xPoz
IF not EXISTS (SELECT name FROM sysindexes WHERE name = 'acKey')
begin
CREATE UNIQUE NONCLUSTERED INDEX [acKey] ON _LogClient
(
[acKey] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [PRIMARY]
ALTER TABLE _LogClient
ADD CONSTRAINT PK_acKeyClient PRIMARY KEY CLUSTERED (acKey);
end