Say I have a table with "column1" (Primary Key, Auto Increment) and "column2".
How can insert into the table with
column2 will have the same values as
column1 which is auto increment column?
You can create a table with a
Calculated column that it's value is equal to column1.
Each time you insert a row into your table column1 will be inserted as identity and column2 will be euqal to that.
CREATE TABLE myTable (column1 int NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) NOT NULL, column2 int); INSERT INTO myTable (name) VALUES('John Doe') UPDATE mytable SET column2 = column1;
You can add other columns like
Sql Server :
CREATE TABLE myTable (column1 int identity (1,1) NOT NULL, name nvarchar(100), column2 as column1); INSERT INTO myTable (name) VALUES('John Doe')