April 22, 2018 at 6:01 am
I use this code:
INSERT INTO
TableIzlez ([BrojNaSmetka],[Artikal],[Sifra],[Kolicina],[Cena_P],[Cena_N],[Prodavac],
[Datum],[Fiskalna],[MasaBroj],[Oddel],[Zatvorena],[PodGrupa],[Cena_Produkti],[TipNaSmetka],[DDV],[Den])
SELECT
BrojNaSmetka,Artikal,Sifra,Kolicina,Cena_P,Cena_N,Prodavac,Datum,
Fiskalna,MasaBroj,Oddel,Zatvorena,PodGrupa,Cena_Produkti,TipNaSmetka,DDV,'19.04.2018'
FROM TableIzlezDneven
Aftrer this code I delete the table TableIzlezDneven
DELETE FROM TableIzlezDneven
Sometimes I get double records at the TableIzlez.
I can't understand why show double records.
In this table with red row show double records ( this is from TableIzlez).
April 22, 2018 at 1:43 pm
mrceski - Sunday, April 22, 2018 6:01 AMI use this code:INSERT INTO
TableIzlez ([BrojNaSmetka],[Artikal],[Sifra],[Kolicina],[Cena_P],[Cena_N],[Prodavac],
[Datum],[Fiskalna],[MasaBroj],[Oddel],[Zatvorena],[PodGrupa],[Cena_Produkti],[TipNaSmetka],[DDV],[Den])
SELECT
BrojNaSmetka,Artikal,Sifra,Kolicina,Cena_P,Cena_N,Prodavac,Datum,
Fiskalna,MasaBroj,Oddel,Zatvorena,PodGrupa,Cena_Produkti,TipNaSmetka,DDV,'19.04.2018'
FROM TableIzlezDnevenAftrer this code I delete the table TableIzlezDneven
DELETE FROM TableIzlezDneven
Sometimes I get double records at the TableIzlez.
I can't understand why show double records.
In this table with red row show double records ( this is from TableIzlez).
Is the TableIzlez table empty before you do the inserts?
--Jeff Moden
Change is inevitable... Change for the better is not.
April 22, 2018 at 1:50 pm
No TableIzlez is not empty.
That table is fill from TableIzlezDneven every day (one time) and TableIzlezDneven is deleted one time per day , and next day start TableIzlezDneven empty.
Thanks for help
April 22, 2018 at 2:09 pm
mrceski - Sunday, April 22, 2018 1:50 PMNo TableIzlez is not empty.
That table is fill from TableIzlezDneven every day (one time) and TableIzlezDneven is deleted one time per day , and next day start TableIzlezDneven empty.Thanks for help
Then the answer is probably pretty simple. There are rows in the TableIzlezDneven table that already exist in the TableIzlez from other loads of the TableIzlezDneven table. There appears to be nothing that you've done to check for duplicates in the TableIzlezDneven from one day 'til the next and you've certainly done nothing to prevent such duplicates from entering the TableIzlez
--Jeff Moden
Change is inevitable... Change for the better is not.
April 22, 2018 at 2:41 pm
Let me clarify what exactly this is about.
It is a restaurant program, where all orders in the restaurant are recorded in TableIzlezDneven during per one day.
At the end of the day, all orders from daily orders (TableIzlezDneven) are transferred to all orders (TableIzlez that database is for records for all days)
and after transferred records table TableIzlezDneven deleted = empty table (DELETE FROM TableIzlezDneven ).
This means that all daylight orders should be transferred to the database for all days. Because they are needed for periodic reports and must be as they are written in the table TzbleIzlezDneven so they can be transferred to the table for all days.
In this picture you will see the some records from TableIzlezDneven transferred on TableIzlez two times (some records - see red line and see the time is some)
see this row where ID=170834 and row ID=170835 is some records but must be only one. In table with red row is duplicate records.
April 22, 2018 at 2:47 pm
you never check the destination table for existing records. Why not?
April 22, 2018 at 3:09 pm
You mean check existing records before INSERTI NTO (transfer from TableIzlezDneven to Tablelzlez) or after INSERT INTO.
April 22, 2018 at 4:04 pm
mrceski - Sunday, April 22, 2018 3:09 PMYou mean check existing records before INSERTI NTO (transfer from TableIzlezDneven to Tablelzlez) or after INSERT INTO.
You first need to ensure that there are no duplicates in the TableIzlezDneven table itself. Then you need to see if any rows in the TableIzlezDneven table already exist in the Tablelzlez.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply