In this tutorial we look at how to Insert Into A Table From Another Table using SQL Server. This is really simple, and always worth learning as I guarantee you that it will save you LOADS of time in your career whether that be restoring database or testing scripts and what's more, it's extremely useful if you are planning to be a Data Analyst.
Tutorial Overview
In this exercise we use the AdventureWorks2019 database (don't worry I link to a tutorial on how to download this), we create a sample table
and then Insert Into the new table from an existing table.
Insert Into From Select Query
The basic premise is that we need to first establish what our SELECT query should be, and we can sense check that data, if any of that data is incorrect (or not appearing how we want it) then we can amend the query to reflect the data. In this tutorial I show you how to change the date column using the GETDATE function and insert into the new table using INSERT INTO SELECT.
As you will see there are multiple ways of doing this, all have their pro's and cons but are all worth knowing. What's more is that this is a really simple tutorial to follow and good practice.
Enjoy it, you might even find it fun.
As always, any questions then let me know in the comments below
Content
00:00 Intro
00:34 Creating a Table
01:31 Exploring the Source Table
02:00 Selecting Values
02:47 Insert Into Multiple Rows
03:10 Insert Into Changing Values
04:22 Removing Columns Insert Into Another Table