MSSQL Insert From Another Table Tutorial

How To Insert Data From Another Table In MSSQL Database Server Tutorial Example

Run microsoft sql server management studio query editor or any client tools you like then copy & paste the below code to insert data into a table from another table usinq sql command or statement in MSSQL Database Server Tutorial Example

   INSERT INTO executives
   SELECT * FROM executives_bak
 
/*
   CREATE TABLE executives
   (
   lastname varchar(50) NOT NULL,
   department varchar(50) NULL,
   join_date date NULL,
   salary numeric(18, 0) NOT NULL
   ) ON [PRIMARY]
*/
   create the table using above code;
   if it is not created yet before inserting.
   also make sure that "executives_bak" is created with some data
   /* */ is multiline code comments in MSSQL
   -- is comment in MSSQL
   -- in fact it is comment in Oracle and MySQL as well

How To Insert Data From Another Table In MSSQL Database Server Tutorial Example - Result in Microsoft Sql Server Management Studio Query Editor Client Tools

No comments:

Post a Comment

leave your comments here..