Update uses all fields in WHERE and fails with datetime.
Posted: Wed 24 Aug 2011 20:59
SQL Server 2008.
I saw this in a previous post:
"SDAC generates update statements in the most efficient way: an update statement contains SET statements only for fields that were changed, and only with the primary key in the WHERE part. Only in case when a table doesn't have primary key, update statement is generated with all fields in the WHERE part. Also you can use the KeyFields property to make SDAC generate an update statement with all fields from the KeyFields property in the WHERE part."
However, our experience is that SDAC generates the update statements with all fields in the WHERE clause. This is not a problem, except when we have a datetime field that changes. Then, the update will succeed randomly, but mostly fails with the error, "Update failed: Found 0 records". In troubleshooting this it appears that the parameter for the datetime field is being set to the correct value, however I also noticed that the datetime size in the field definition is 8 and the parameter size is 7. Could that be what's causing the problem? If not, what can we do, other than removing all the datetime fields from the generated WHERE clause.
Thanks! Dave
I saw this in a previous post:
"SDAC generates update statements in the most efficient way: an update statement contains SET statements only for fields that were changed, and only with the primary key in the WHERE part. Only in case when a table doesn't have primary key, update statement is generated with all fields in the WHERE part. Also you can use the KeyFields property to make SDAC generate an update statement with all fields from the KeyFields property in the WHERE part."
However, our experience is that SDAC generates the update statements with all fields in the WHERE clause. This is not a problem, except when we have a datetime field that changes. Then, the update will succeed randomly, but mostly fails with the error, "Update failed: Found 0 records". In troubleshooting this it appears that the parameter for the datetime field is being set to the correct value, however I also noticed that the datetime size in the field definition is 8 and the parameter size is 7. Could that be what's causing the problem? If not, what can we do, other than removing all the datetime fields from the generated WHERE clause.
Thanks! Dave