



-- Einen bestimmten Artikel über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'ART' as "table", ART_ID as "key", getdate() AS "datum" FROM dbo.ART WHERE [Artikelnummer]='2001320')


-- Alle aktiven Artikel über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'ART' as "table", ART_ID as "key", getdate() AS "datum" FROM dbo.ART WHERE [Inaktiv]='0')


-- Alle shopaktiven Artikel über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'ART' as "table", ART_ID as "key", getdate() AS "datum" FROM dbo.ART WHERE [Shopaktiv]='1')


-- Alle Artikel mit HTMLText über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
	(SELECT 'UPDATE' AS "command", 'ART' as "table", A.ART_ID as "key", getdate() AS "datum"
		FROM dbo.ART A
		LEFT JOIN dbo.TEXT T ON T.BLOBKEY=CONCAT('AS', A.Artikelnummer)
		WHERE T.HTMLText IS NOT NULL
	)


-- Ein bestimmtes Bild über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'BILD' as "table", BILD_ID as "key", getdate() AS "datum" FROM dbo.BILD WHERE [Blobkey]='AR2004806')


-- Alle Bilder von aktiven Artikeln über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
	(SELECT 'UPDATE' AS "command", 'BILD' as "table", B.BILD_ID as "key", getdate() AS "datum"
		FROM dbo.BILD B LEFT JOIN dbo.ART A ON B.[Blobkey]=CONCAT('AR', A.Artikelnummer) WHERE A.[Inaktiv]='0'
	)


-- Alle Bilder von shopaktiven Artikeln über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
	(SELECT 'UPDATE' AS "command", 'BILD' as "table", B.BILD_ID as "key", getdate() AS "datum"
		FROM dbo.BILD B LEFT JOIN dbo.ART A ON B.[Blobkey]=CONCAT('AR', A.Artikelnummer) WHERE A.[Shopaktiv]='1'
	)


-- Einen bestimmten Kunden über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'DEBITOREN' as "table", KUNDEN_ID as "key", getdate() AS "datum" FROM dbo.DEBITOREN WHERE [Nummer]='10004')


-- Einen bestimmten Kontakt über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'CRM_ADRESSEN' as "table", CRM_ADRESSEN_ID as "key", getdate() AS "datum" FROM dbo.CRM_ADRESSEN WHERE [CRM_ADRESSEN_ID]='9')


-- Alle Aufträge eines bestimmten Kunden über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'BELEG' as "table", BELEG_ID as "key", getdate() AS "datum" FROM dbo.BELEG WHERE "Belegtyp" IN ('F') AND "Adressnummer" IN ('10042'))


-- Alle Aufträge von Shop-Aktiven Kontakten synchronisieren
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
	(SELECT 'UPDATE' AS "command", 'BELEG' as "table", BELEG_ID as "key", getdate() AS "datum" 
		FROM dbo.BELEG B
			LEFT JOIN dbo.DEBITOREN          D ON D.Nummer = B.Adressnummer
			LEFT JOIN dbo.CRM_ADRESSEN       A ON A.Id = D.CRM_AdressenID
			LEFT JOIN dbo.CRM_PERSONENLINK  PL ON PL.AdresseID = A.CRM_ADRESSEN_ID
			LEFT JOIN dbo.CRM_ADRESSEN      KA ON KA.CRM_ADRESSEN_ID = PL.PersonID
		WHERE B.Belegtyp IN ('F')
			AND KA._SHOPAKTIV=1
		GROUP BY B.BELEG_ID
	)




-- Einen bestimmten Auftrag über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'BELEG' as "table", BELEG_ID as "key", getdate() AS "datum" FROM dbo.BELEG WHERE "Belegtyp" IN ('F') AND "Belegnummer" IN ('403062'))




-- Alle Tickets über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'BELEGP' as "table", BELEGP_ID as "key", getdate() AS "datum" FROM dbo.BELEGP WHERE "Zeilentyp" IN('S'))



-- Alle Aufträge über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'BELEG' as "table", BELEG_ID as "key", getdate() AS "datum" FROM dbo.BELEG WHERE "Belegtyp" IN ('F'))



-- Alle Artikel über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'ART' as "table", ART_ID as "key", getdate() AS "datum" FROM dbo.ART WHERE 1=1)



-- Alle Bilder über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'BILD' as "table", BILD_ID as "key", getdate() AS "datum" FROM dbo.BILD WHERE 1=1)



-- Alle Positionen über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'BELEGP' as "table", BELEGP_ID as "key", getdate() AS "datum" FROM dbo.BELEGP WHERE 1=1)



-- Alle Preise über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'ARPREIS' as "table", ARPREIS_ID as "key", getdate() AS "datum" FROM dbo.ARPREIS WHERE 1=1)



-- Alle Projekte über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'WPROJEKT' as "table", WPROJEKT_ID as "key", getdate() AS "datum" FROM dbo.WPROJEKT WHERE 1=1)



-- Alle Rabattgruppen über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'RABGRUP' as "table", RABGRUP_ID as "key", getdate() AS "datum" FROM dbo.RABGRUP WHERE 1=1)



-- Alle Zubehoer-Zeilen über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'ZUBEHOER' as "table", ZUBEHOER_ID as "key", getdate() AS "datum" FROM dbo.ZUBEHOER WHERE 1=1)







-- Alle Kunden über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'DEBITOREN' as "table", KUNDEN_ID as "key", getdate() AS "datum" FROM dbo.DEBITOREN WHERE 1=1)


-- Alle Adressen-Zeilen über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'ADRESS' as "table", ADRESS_ID as "key", getdate() AS "datum" FROM dbo.ADRESS WHERE dbo.ADRESS.ADRESS_ID IN (23707))


-- Alle CRM-Adressen-Zeilen über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'CRM_ADRESSEN' as "table", CRM_ADRESSEN_ID as "key", getdate() AS "datum" FROM dbo.CRM_ADRESSEN WHERE 1=1)


-- Alle Interessenten-Zeilen über die Schnittstelle updaten
INSERT INTO dbo.ceRem3_sync ("command", "table", "key", "datum") 
  (SELECT 'UPDATE' AS "command", 'WAWIINTERESS' as "table", INTERESS_ID as "key", getdate() AS "datum" FROM dbo.WAWIINTERESS WHERE 1=1)



-- Alle Artikel auf Shop-Aktiv NEIN setzen
UPDATE dbo.ART SET "ShopAktiv"=0;




