Sql-server – Unable to update or insert values table with DateTime column defaulted to GETDATE

alter-tabledatetimesql serversynonymstrigger

I have atlered table by adding Datetime column. This column is not null and also default value from GETDATE().

ALTER TABLE myTable ADD myDateColun DATETIME NOT NULL DEFAULT (GETDATE())

I'm trying to update, I'm unable to update or insert values table

update  myTable set myDateColun = GETDATE() where id = someNumber

Its throwing me SQL error

Column name or number of supplied values does not match table
definition.

Note: This table has trigger defined on insert and delete scenario for data, which updates synonym table linked to this table in other database.

Any ideas what can be reason for SQL errors in above scenario?

Best Answer

My guess is that your trigger has a "insert into ... select * from myTable" kind of structure, and now it's broken because there's one more column in the table. Change your trigger so that it lists the columns instead of using *.