Insert Command - DotNet and DataBase

Follow us on Facebook

SQL Server Mountain View Mountain View Mountain View

Wednesday, 1 August 2018

Insert Command

Insert command is used to append data into an existing table.

INSERT INTO <Tablename>(Col1,Col2,col3, etc..)
VALUES (val1,val2val3,etc...);


INSERT INTO EmployeeInfo(EmpName,EmpDept,EmpLevel,EmpAddress,EmpPhone,UserName,[Password],Email)
VALUES ('Sudhakar','Accounts',3,'Meerpet',8897998408,'Sudhakar','123','');

Inserting only values:
INSERT INTO EmployeeInfo VALUES (1,'Sudhakar',2,3,'Meerpet',8897998408,'Sudhakar','123','');

Inserting one table data into another table:

1)INSERT INTO <tablename1>
  SELECT * FROM <tablename2>

2)INSERT INTO <tablename1>(Col1,Col2,Col3,etc..)VALUES

  SELECT Col1,Col2,Col3,etc... FROM <tablename2>


1)INSERT INTO EmployeeInfo
  SELECT * FROM EmployeeInfo2

2)INSERT INTO EmployeeInfo(EmpName,EmpDept,EmpLevel)VALUES
  SELECT (EmpName,EmpDept,EmpLevel) FROM EmployeeInfo2

No comments:

Post a comment


Get Updates On

Discussion updates

Straight Into Your INBOX!

Enter your email address to subscribe to this website and receive notifications of new posts by email.