Tutorial by Examples

A computed column is computed from an expression that can use other columns in the same table. The expression can be a noncomputed column name, constant, function, and any combination of these connected by one or more operators. Create table with a computed column Create table NetProfit ( Sa...
CREATE TABLE [dbo].[ProcessLog]( [LogId] [int] IDENTITY(1,1) NOT NULL, [LogType] [varchar](20) NULL, [StartTime] [datetime] NULL, [EndTime] [datetime] NULL, [RunMinutes] AS (datediff(minute,coalesce([StartTime],getdate()),coalesce([EndTime],getdate()))) This gives run difference in minutes ...

Page 1 of 1