Insert records using select statement

Rajni.Shekhar
Posted by Rajni.Shekhar under Sql Server category on | Points: 40 | Views : 991

---CREATE TABLES
CREATE TABLE myTable (ID INT NOT NULL IDENTITY,
Name CHAR(50) NOT NULL,
AGE INT NOT NULL,
[ADDRESS] VARCHAR(100) NULL,
PINCODE VARCHAR(6)
)

CREATE TABLE testTable (ID INT NOT NULL,
Name CHAR(50) NOT NULL,
AGE INT NOT NULL
)

----INSERT VALUES IN TABLE
insert into myTable values ('XYZ', 20, 'DELHI','202020')
insert into myTable values ('ABC', 30, 'CHENNAI','111111')

--insert records into testTable from myTable.
Insert into testTable
Select ID, Name, Age from myTable

Comments or Responses

Login to post response