/****** Object: Table [dbo].[Sample1] Script Date: 5/9/2018 3:59:09 PM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Sample1](
[ID] [INT] IDENTITY(1,1) NOT NULL,
[UnitPrice] [DECIMAL](16, 2) NOT NULL,
[Quantity] [DECIMAL](10, 2) NOT NULL,
[TotalAmount] AS ([UnitPrice]*[Quantity]),
CONSTRAINT [PK_Sample1] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
INSERT INTO dbo.Sample1
( UnitPrice, Quantity )
VALUES ( 100, -- UnitPrice - decimal
25 -- Quantity - decimal
)
SELECT * FROM dbo.Sample1
---OUTPUT------------
ID UnitPrice Quantity TotalAmount
1 100.00 25.00 2500.0000