SQL Server guide

Update event


This example updates an existing event by ID. You can change summary, description, times, location, attendees, reminders, and other fields. Use dynamic placeholders for relative times (e.g. <>).

Note: Always provide time zones for timed events. You can choose whether to notify attendees of the update.

Standard SQL query example

This is the base query accepted by the connector. To execute it in SQL Server, you have to pass it to the Data Gateway via a Linked Server. See how to accomplish this using the examples below.

UPDATE Events
SET	 Summary = 'Project Kickoff Meeting'            -- Event title
    ,Description = 'Your meeting description in <strong>bold HTML</strong>'
    
    --For all day event - Example '2026-01-28'
    --,StartsOn = '2026-02-01'                        -- All-day event start date (YYYY-MM-DD)    
    --,EndsOn = '2026-02-01'                          -- All-day event end date (YYYY-MM-DD)
    
    --,StartsOn = '<<monthend+1d,FUN_TO_DATE>>'      -- Dynamic date example
    --,EndsOn   = '<<monthend+1d,FUN_TO_DATE>>'
    
    --OR--

    --For events which has start/end time : Example '2026-01-28T15:59:00'
    ,StartsAt = '<<today+1d+10h,FUN_TO_DATETIME>>' -- Set time from today + 1 day + 10 hours (10AM)
    ,EndsAt = '<<today+1d+11h,FUN_TO_DATETIME>>'   -- Set time from today + 1 day + 11 hours (11AM)
    ,StartsInTimeZone = 'America/New_York'
    ,EndsInTimeZone = 'America/New_York'
        
    ,Location = 'Conference Room 2B'                -- Event location
    ,Attendees = '[{"email":"user1@example.com"},{"email":"user2@example.com"}]' -- JSON array of attendees
	,RemindersUseDefault = false                    -- Use custom reminders
	,RemindersOverrides = '[{"method": "popup","minutes": 12},{"method": "popup","minutes": 11}]'  -- JSON array of reminder overrides
    ,Recurrence = '["RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20260131T045959Z;BYDAY=MO,WE"]'      -- Recurrence rule
    ,Status = 'confirmed'                           -- confirmed | tentative | cancelled
    ,Transparency = 'opaque'                        -- opaque | transparent
    ,Visibility = 'default'                         -- default | public | private | confidential
    ,ColorId = '5'                                  -- Color identifier
    ,GuestsCanInviteOthers = true                   -- Allow guests to invite others
    ,GuestsCanModify = false                        -- Allow guests to modify event
    ,GuestsCanSeeOtherGuests = true                 -- Allow guests to see other guests
    ,AnyoneCanAddSelf = false                       -- Anyone can add themselves as attendee
    ,PrivateCopy = false                            -- Private event copy
    ,ShowMeAs = 'busy'                              -- busy | free | tentative | workingElsewhere
    ,SourceTitle = 'Project Plan'                   -- Source title
    ,SourceUrl = 'https://example.com/project-plan' -- Source URL
WHERE Id = '5hr02mkhg09atao1clih4jco6e'  -- Event ID to update
WITH (
   CalendarId = 'primary' --or 'some-calendar-id'
 , SendUpdates='none' --'all' or 'externalOnly' to notify attendees
)

Using OPENQUERY in SQL Server

SELECT * FROM OPENQUERY([LS_TO_GOOGLE_CALENDAR_IN_GATEWAY], 'UPDATE Events
SET	 Summary = ''Project Kickoff Meeting''            -- Event title
    ,Description = ''Your meeting description in <strong>bold HTML</strong>''
    
    --For all day event - Example ''2026-01-28''
    --,StartsOn = ''2026-02-01''                        -- All-day event start date (YYYY-MM-DD)    
    --,EndsOn = ''2026-02-01''                          -- All-day event end date (YYYY-MM-DD)
    
    --,StartsOn = ''<<monthend+1d,FUN_TO_DATE>>''      -- Dynamic date example
    --,EndsOn   = ''<<monthend+1d,FUN_TO_DATE>>''
    
    --OR--

    --For events which has start/end time : Example ''2026-01-28T15:59:00''
    ,StartsAt = ''<<today+1d+10h,FUN_TO_DATETIME>>'' -- Set time from today + 1 day + 10 hours (10AM)
    ,EndsAt = ''<<today+1d+11h,FUN_TO_DATETIME>>''   -- Set time from today + 1 day + 11 hours (11AM)
    ,StartsInTimeZone = ''America/New_York''
    ,EndsInTimeZone = ''America/New_York''
        
    ,Location = ''Conference Room 2B''                -- Event location
    ,Attendees = ''[{"email":"user1@example.com"},{"email":"user2@example.com"}]'' -- JSON array of attendees
	,RemindersUseDefault = false                    -- Use custom reminders
	,RemindersOverrides = ''[{"method": "popup","minutes": 12},{"method": "popup","minutes": 11}]''  -- JSON array of reminder overrides
    ,Recurrence = ''["RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20260131T045959Z;BYDAY=MO,WE"]''      -- Recurrence rule
    ,Status = ''confirmed''                           -- confirmed | tentative | cancelled
    ,Transparency = ''opaque''                        -- opaque | transparent
    ,Visibility = ''default''                         -- default | public | private | confidential
    ,ColorId = ''5''                                  -- Color identifier
    ,GuestsCanInviteOthers = true                   -- Allow guests to invite others
    ,GuestsCanModify = false                        -- Allow guests to modify event
    ,GuestsCanSeeOtherGuests = true                 -- Allow guests to see other guests
    ,AnyoneCanAddSelf = false                       -- Anyone can add themselves as attendee
    ,PrivateCopy = false                            -- Private event copy
    ,ShowMeAs = ''busy''                              -- busy | free | tentative | workingElsewhere
    ,SourceTitle = ''Project Plan''                   -- Source title
    ,SourceUrl = ''https://example.com/project-plan'' -- Source URL
WHERE Id = ''5hr02mkhg09atao1clih4jco6e''  -- Event ID to update
WITH (
   CalendarId = ''primary'' --or ''some-calendar-id''
 , SendUpdates=''none'' --''all'' or ''externalOnly'' to notify attendees
)')

Using EXEC in SQL Server (handling larger SQL text)

The major drawback of OPENQUERY is its inability to incorporate variables within SQL statements. This often leads to the use of cumbersome dynamic SQL (with numerous ticks and escape characters).

Fortunately, starting with SQL 2005 and onwards, you can utilize the EXEC (your_sql) AT [LS_TO_GOOGLE_CALENDAR_IN_GATEWAY] syntax.

DECLARE @MyQuery NVARCHAR(MAX) = 'UPDATE Events
SET	 Summary = ''Project Kickoff Meeting''            -- Event title
    ,Description = ''Your meeting description in <strong>bold HTML</strong>''
    
    --For all day event - Example ''2026-01-28''
    --,StartsOn = ''2026-02-01''                        -- All-day event start date (YYYY-MM-DD)    
    --,EndsOn = ''2026-02-01''                          -- All-day event end date (YYYY-MM-DD)
    
    --,StartsOn = ''<<monthend+1d,FUN_TO_DATE>>''      -- Dynamic date example
    --,EndsOn   = ''<<monthend+1d,FUN_TO_DATE>>''
    
    --OR--

    --For events which has start/end time : Example ''2026-01-28T15:59:00''
    ,StartsAt = ''<<today+1d+10h,FUN_TO_DATETIME>>'' -- Set time from today + 1 day + 10 hours (10AM)
    ,EndsAt = ''<<today+1d+11h,FUN_TO_DATETIME>>''   -- Set time from today + 1 day + 11 hours (11AM)
    ,StartsInTimeZone = ''America/New_York''
    ,EndsInTimeZone = ''America/New_York''
        
    ,Location = ''Conference Room 2B''                -- Event location
    ,Attendees = ''[{"email":"user1@example.com"},{"email":"user2@example.com"}]'' -- JSON array of attendees
	,RemindersUseDefault = false                    -- Use custom reminders
	,RemindersOverrides = ''[{"method": "popup","minutes": 12},{"method": "popup","minutes": 11}]''  -- JSON array of reminder overrides
    ,Recurrence = ''["RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20260131T045959Z;BYDAY=MO,WE"]''      -- Recurrence rule
    ,Status = ''confirmed''                           -- confirmed | tentative | cancelled
    ,Transparency = ''opaque''                        -- opaque | transparent
    ,Visibility = ''default''                         -- default | public | private | confidential
    ,ColorId = ''5''                                  -- Color identifier
    ,GuestsCanInviteOthers = true                   -- Allow guests to invite others
    ,GuestsCanModify = false                        -- Allow guests to modify event
    ,GuestsCanSeeOtherGuests = true                 -- Allow guests to see other guests
    ,AnyoneCanAddSelf = false                       -- Anyone can add themselves as attendee
    ,PrivateCopy = false                            -- Private event copy
    ,ShowMeAs = ''busy''                              -- busy | free | tentative | workingElsewhere
    ,SourceTitle = ''Project Plan''                   -- Source title
    ,SourceUrl = ''https://example.com/project-plan'' -- Source URL
WHERE Id = ''5hr02mkhg09atao1clih4jco6e''  -- Event ID to update
WITH (
   CalendarId = ''primary'' --or ''some-calendar-id''
 , SendUpdates=''none'' --''all'' or ''externalOnly'' to notify attendees
)'
EXEC (@MyQuery) AT [LS_TO_GOOGLE_CALENDAR_IN_GATEWAY]