Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 insert

Author  Topic 

mana
Posting Yak Master

102 Posts

Posted - 2014-09-24 : 03:33:32
Hello

I have a table as dbo.Bewegungen and it will be updated every day with new dates
I inserted once the values of this table to another table with group by. I want to know how should i insert the new valuse every day to the new table? i don't want to insert the previous valus again.
it has 5 columns as primary key and one of them is Date.
Can you help me please?
Thank you

Arun Babu N
Starting Member

26 Posts

Posted - 2014-09-24 : 03:35:02
use not exists

arunbabu
Go to Top of Page

mana
Posting Yak Master

102 Posts

Posted - 2014-09-24 : 04:28:04
how should i use not exists
can you help me please?
for example the below code doesn't work
i have 5 primary keys : datum, teil,id,workcenter and reason-code


insert into dbo.Table_2
SELECT b.Datum_Bewegung, b.Teil_Nummer, b.Workcenter, b.Reason_Code, b.Menge,
b.Id_Nr, b.Mengeneinheit FROM dbo.Bewegungen_Inventur_Korrekturen b
WHERE not exists (SELECT * FROM dbo.Table_2 a WHERE b.Datum_Bewegung = a.Datum_Bewegung
and b.Teil_Nummer=a.Teil_Nummer
and b.Workcenter=a.Workcenter
and b.Reason_Code=a.Reason_Code
and b.Id_Nr=a.Id_Nr)









quote:
Originally posted by Arun Babu N

use not exists

arunbabu

Go to Top of Page
   

- Advertisement -