I'm working on several triggers (that happen after insert or update) in order to log the changes in a different table.
They all follow a similar syntax and are working fine, except for this one...
I've reduced the next code to the minimum that gives an error, so we can safely assume the other parts of the trigger are working fine.
INSERT INTO [Adt].[WardUnitStayLog]
FROM [Adt].[WardUnitStay] t
INNER JOIN inserted i
ON i.[Id] = t.[Id];
I've used this same syntax (but on different tables) in other triggers, and these are working perfectly fine. The above query provides the next error:
Column name or number of supplied values does not match table definition.
I've checked both tables for differences in the columns, but to no avail... (I've checked them manually and by outerjoining the information_schema.columns) (I've also checked the order in wich these columns are defined, they match over the two tables)
These are the creation scripts for the tables:
CREATE TABLE [Adt].[WardUnitStay]
[Id] [dbo].[Id] IDENTITY(1,1) NOT NULL,
[UnifiedUnitStayId] [dbo].[Id] NOT NULL,
[WardCd] [dbo].[Cd] NOT NULL,
[_FirstAtTm] [dbo].[Dtm] NOT NULL,
[_IsReservation] BIT NOT NULL,
[_LastAtTm] [dbo].[Dtm] NOT NULL,
[_LastBedCd] [dbo].[Cd] NULL,
View Complete Post