ms access sql select insert into code example

Example 1: sql add statement access

INSERT INTO tblProducts (ProductName,
   CategoryDescription, UnitPrice)
VALUES ('Support Renewal', 'Multi-User', 99);

Example 2: sql add statement access

PARAMETERS LastDateToKeep DateTime;
INSERT INTO tblContactEventsHistory
  (ContactID, ContactDateTime, ContactEventType, ContactNotes )
 SELECT tblContactEvents.ContactID, tblContactEvents.ContactDateTime,
   tlkpContactEventTypes.ContactEventTypeDescription,
   tblContactEvents.ContactNotes
  FROM tlkpContactEventTypes
  INNER JOIN (tblContactEvents
   LEFT JOIN tblContactEventsHistory
   ON (tblContactEvents.ContactID = tblContactEventsHistory.ContactID)
    AND (tblContactEvents.ContactDateTime =
     tblContactEventsHistory.ContactDateTime))
  ON tlkpContactEventTypes.ContactEventTypeID =
   tblContactEvents.ContactEventTypeID
 WHERE (tblContactEvents.ContactDateTime<[LastDateToKeep])
  AND (tblContactEventsHistory.ContactID Is Null);

Tags:

Sql Example