SQL INSERT INTO SELECT STATEMENT

The SQL INSERT INTO SELECT is used when copying the selected columns from one table and inserting them into another table. The data types for the source and target tables must match for the SQL INSERT INTO SELECT query to work.

  • Syntax of SQL INSERT INTO SELECT – 

SQL INSERT INTO SELECT

The SQL statement in this case moves all data from the Old Table to the New Table.

OR, Copy Selected Columns Only

SQL INSERT INTO SELECT into Specify Columns

Likewise, this SQL Statement Only copies records from the old table to selected columns.

Demo table –

The below table represents a section of the Products table –

The below table represents a section of the Managers table –

Example – From the below demo tables, insert the name “Regional Manager” from Manager Table to Product Table “Customer Name”.

The output after applying the above INSERT INTO SELECT –

Here basically, all the other columns are “NULL” as only the “Customers Name” values were inserted from the Manager’s table.

Follow us on TwitterFacebookLinkedin, and Tableau Public to stay updated with our latest blog and what’s new in Tableau.

 

Automate data analysis pipeline and create report ready dashboards

If you are looking forward to getting your data pipeline built and setting up the dashboard for business intelligence, book your strategy session now from here.

#analytics #data #business #artificialintelligence #machinelearning #startup #deeplearning #deeplearning #datascience #ai #growth #dataanalytics #india #datascientist #powerbi #dataanalysis #tableau #SQL #businessanalytics #businessanalyst #businessandmanagement #dataanalyst #businessanalysis #analyst #analysis #powerbideveloper #powerbidesktop #letsviz