Change The Value Of Computed Column In Specific Conditions
I have a table for Library Circulation that have a column named 'Delay'. This column is a computed column, but it should be changed until the 'IsReturned' (another column in this t
Solution 1:
Referring to a computed column in a computed column definition is not allowed. You need to record the times that the item is checked out and returned rather than using a BIT field. You can use those values to define your computed column. For example:
CREATE TABLE Checkouts
(
CheckoutId INT IDENTITY NOT NULL PRIMARY KEY,
CheckedOut DATETIME NOT NULL DEFAULT (getdate()),
CheckedIn DATETIME NULL,
DelayDays AS (datediff(day, CheckedOut, COALESCE(CheckedIn, getdate())))
)
Post a Comment for "Change The Value Of Computed Column In Specific Conditions"