Skip to content

Commit d58ecc4

Browse files
authored
Merge pull request #190157 from Fleid/patch-10
Update sql-database-upsert.md
2 parents 35f3833 + d480192 commit d58ecc4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

articles/stream-analytics/sql-database-upsert.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,15 @@ Outside of Azure Functions, there are multiple ways to achieve the expected resu
380380

381381
A background task will operate once the data is inserted in the database via the standard ASA SQL outputs.
382382

383-
For Azure SQL, `INSTEAD OF` [DML triggers](/sql/relational-databases/triggers/dml-triggers?view=azuresqldb-current&preserve-view=true) can be used to intercept the INSERT commands issued by ASA and replace them with UPDATE or MERGE:
383+
For Azure SQL, `INSTEAD OF` [DML triggers](/sql/relational-databases/triggers/dml-triggers?view=azuresqldb-current&preserve-view=true) can be used to intercept the INSERT commands issued by ASA:
384384

385385
```SQL
386386
CREATE TRIGGER tr_devices_updated_upsert ON device_updated INSTEAD OF INSERT
387387
AS
388388
BEGIN
389389
MERGE device_updated AS old
390+
391+
-- In case of duplicates on the key below, use a subquery to make the key unique via aggregation or ranking functions
390392
USING inserted AS new
391393
ON new.DeviceId = old.DeviceId
392394

0 commit comments

Comments
 (0)