April 4, 2019 at 3:25 pm
hi ,
I have Audit table , where i have to update the Totals as Inserts + Updates. I created a table already and now i am trying to Alter it. Below is the code , but it is not working.
ALTER TABLE [dbo].[ssis_audit]
ADD CONSTRAINT df_ADDTotal DEFAULT ([Inserts] + [Updates]) FOR [TotalRecords]
What is wrong with the code? can any one please suggest?
April 4, 2019 at 3:31 pm
Assuming you have columns named "Inserts" and "Updates", this will not work for a default constraint.
You will need to create a persisted computed column.
But the question is why? If you are creating a query of this table, why won't simply selecting Inserts, Updates, and Inserts + Updates as TotalRecords suffice?
Michael L John
If you assassinate a DBA, would you pull a trigger?
To properly post on a forum:
http://www.sqlservercentral.com/articles/61537/
April 4, 2019 at 3:33 pm
Hi,
Instead of using DEFAULT constraint, this is probably a better scenario for computed column.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply