SQL Insert into more than one table SQL SERVER

If you are reading this then you probably want to create a table in SQL server using the Create Table As statement.  Essentially you want to create the a new table based on one or more tables.

Here is how you do that.  Instead of issuing a CREATE TABLE AS . . .” statement, you simply put an “into TABLE_NAME” before the from statement in your SQL statement.  See the examples below.

Select column1, column2, column3
Insert dbo.New_table_name
From dbo.table_name

If you had two tables that were alike and you wanted to create a new table containing the values found in both tables, then you would write the following query.

Select *
Into dbo.new_table_name
From dbo.old_table_one
Union All
Select *
From dbo.old_table_two


Leave a comment

Filed under Sharing Stuff

Comment on this

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s