dotnet / dotnet/EntityFramework.Docs
example for inserted trigger doesn't work with multiple rows
- Dominant language
- Mermaid
- Stars
- 1.7k
- Forks
- 2k
- Avg merge
- 7d 23h
- Merged PRs (30d)
- 16
Description
The example `CREATE TRIGGER [dbo].[Blogs_UPDATE] ON [dbo].[Blogs]` only deals with a single row. It does not work with all rows in the virtual INSERTED table
Something like this will work for ALL updated rows.
```
CREATE TRIGGER [dbo].[Blogs_UPDATE] ON [dbo].[Blogs]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;
IF ((SELECT TRIGGER_NESTLEVEL()) > 1) RETURN;
UPDATE dbo.Blogs
SET LastUpdated = GETDATE()
FROM dbo.Blogs
JOIN INSERTED on Blogs.BlogId = INSERTED.BlogId
END
```
---
#### Document Details
⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*
* ID: 97d622b2-1e4b-4d76-b3df-fefaa5ba99cb
* Version Independent ID: ec833af2-275e-981f-689f-8c65edfc00cd
* Content: [Generated Values - EF Core](https://docs.microsoft.com/en-us/ef/core/modeling/generated-properties?tabs=data-annotations)
* Content Source: [entity-framework/core/modeling/generated-properties.md](https://github.com/dotnet/EntityFramework.Docs/blob/master/entity-framework/core/modeling/generated-properties.md)
* Product: **entity-framework**
* Technology: **entity-framework-core**
* GitHub Login: @AndriySvyryd
* Microsoft Alias: **avickers**
Contributor guide
Assessment
This issue has not been assessed yet.