Link to home
Start Free TrialLog in
Avatar of Shivanand Bhangari
Shivanand Bhangari

asked on

How to merge all multiple tables with a single blank table in SQL?

There are multiple tables, all tables are having same column names with different values, nd I have created one new table with same columns , but I want to put those all data in this new crated single table in SQL. There is no unique id in any of the table. I just want to merge all table data in one sinlge table.

Table names are - Andra Pradesh, Arunachal Pradesh, Assam, Bihar, Chhattisgarh,Delhi,Hariyana,Himachal Pradesh, Karnataka.
      
And all column names are same in all the tables , here is the column names - State, District,Year,January,February,March,April,May,June,July,Aug‌​ust,September,Octobe‌​r,NovemberDecember. And tbl_India this is the new table which I created with the same columns.... I want to add those all data in this new table.
ASKER CERTIFIED SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shivanand Bhangari
Shivanand Bhangari

ASKER

executed successfully but the datas are not merged in blank table.
SOLUTION
Avatar of Terry Woods
Terry Woods
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here it is ! Enjoy !

--

INSERT INTO TableName [Cols]
SELECT [col_name] FROM tablea
UNION ALL
SELECT [col_name] FROM tableb


--

Open in new window


--
Hi!

Depending on the overall data-size of all the tables you want to merge into the new table.
If the size is over 5 million records then I strongly recommend that you partition the table in such way that you have near-even distribution and the partitioning benefits most or all queries that access the table.

Regards,
      Tomas Helgi