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-10-16 : 05:41:52
Hello,

i wrote the following insert but it has problem and i can't understand where the problem is. i want to add data to Reporting.dbo.Nacharbeitmanagement_from_AQIS from a view and in this table
datum_offline and Auftrag are primary key. I dont't want that the repeated rows will be added.
can you guid eme please?
thnak you for your help

insert into Reporting.dbo.Nacharbeitmanagement_from_AQIS(Auftrag, Datum_Offline, Seriennummer, Benennung, Land, Letzter_Platz, AVG_RepZeit_Offen, AnzFehler_Offen, AVG_RepZeit_Total, AnzFehler_Total)
select a.* from
(select Auftrag, Datum_Offline, Seriennummer, Benennung, Land, Letzter_Platz, AVG_RepZeit_Offen, AnzFehler_Offen, AVG_RepZeit_Total, AnzFehler_Total
FROM dbo.v_Nacharbeits_Forcast) as a
left join Reporting.dbo.Nacharbeitmanagement_from_AQIS b
where b.Datum_Offline is null;

mmkrishna1919
Yak Posting Veteran

95 Posts

Posted - 2014-10-16 : 07:14:33
The join condition is missed.

where a.Auftrag = b.Auftrag
and a.Datum_Offline = b.Datum_Offline
and b.Datum_Offline is null;

M.MURALI kRISHNA
Go to Top of Page
   

- Advertisement -