Tekrar Eden Stok ve Cari Hareketleri Silmek
;WITH STHARCTE(STOK_KODU, FISNO,STHAR_TARIH, STHAR_GCKOD,STHAR_GCMIK, STHAR_NF,STHAR_ACIKLAMA,STHAR_FTIRSIP, Ranking)
AS
(
SELECT
STOK_KODU, FISNO,STHAR_TARIH, STHAR_GCKOD,STHAR_GCMIK, STHAR_NF,STHAR_ACIKLAMA,STHAR_FTIRSIP,
Ranking = DENSE_RANK() OVER(PARTITION BY STOK_KODU, FISNO,STHAR_TARIH, STHAR_GCKOD,STHAR_GCMIK, STHAR_NF,STHAR_ACIKLAMA,STHAR_FTIRSIP ORDER BY NEWID() ASC)
FROM TBLSTHAR
)
SELECT *
--DELETE
FROM STHARCTE
WHERE Ranking > 1
;WITH CAHARCTE(CARI_KOD, TARIH,VADE_TARIHI, BELGE_NO,ACIKLAMA, HKA,BORC,ALACAK, Ranking)
AS
(
SELECT
CARI_KOD, TARIH,VADE_TARIHI, BELGE_NO,ACIKLAMA, HKA,BORC,ALACAK,
Ranking = DENSE_RANK() OVER(PARTITION BY CARI_KOD, TARIH,VADE_TARIHI, BELGE_NO,ACIKLAMA, HKA,BORC,ALACAK ORDER BY NEWID() ASC)
FROM TBLCAHAR
)
SELECT *
--DELETE
FROM CAHARCTE
WHERE Ranking > 1