Computational column : Create Table « Table « SQL Server / T-SQL Tutorial






6> CREATE TABLE T (
7>     int1 int,
8>     bit1 bit,
9>     varchar1 varchar(3),
10>     dec1 dec(5,2),
11>     cmp1 AS (int1 + bit1)
12> )
13> GO
1>
2> INSERT T (int1, bit1) VALUES (1, 0)
3> INSERT T (int1, varchar1) VALUES (2, 'abc')
4> INSERT T (int1, dec1) VALUES (3, 5.25)
5> INSERT T (bit1, dec1) VALUES (1, 9.75)
6> GO

(1 rows affected)

(1 rows affected)

(1 rows affected)

(1 rows affected)
1>
2> drop table t;
3> GO








3.1.Create Table
3.1.1.The basic syntax of the CREATE TABLE statement
3.1.2.PRIMARY KEY column
3.1.3.Table Creation Script for Parent and Child with FOREIGN KEY Constraint and INSTEAD OF Trigger
3.1.4.Computational column
3.1.5.CLUSTERED column
3.1.6.A statement that creates a table with column attributes