MSSQLTips.com - your daily source for SQL Server tips

Google
 
Web mssqltips.com

ESSENTIALS: Home | Tips | Search | Categories | Top 10 | Products | Authors | Blogs | Forums | Webcasts | Advertise | About
SQL QUERY TO PUT THE DATA FROM ALL THE TABLES INTO ONE -

in Search

SQL QUERY TO PUT THE DATA FROM ALL THE TABLES INTO ONE

Last post 06-18-2008 4:46 AM by aami83. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 04-16-2008 4:07 AM

    • aami83
    • Top 100 Contributor
    • Joined on 04-16-2008
    • Posts 2

    SQL QUERY TO PUT THE DATA FROM ALL THE TABLES INTO ONE

    Dear all please help i am using MC ACCESS i have 56 tables in my access database i want to creat a query in which i can see the data from all the tables into one table please note that all columns are same in all the tables right no i  am using this query

    INSERT INTO
    alldata select * from personal

     but this query is giving me the data for only ome table please send me complete query that give me the data for all the tables

     

     

  • 04-16-2008 10:49 AM In reply to

    • aprato
    • Top 10 Contributor
    • Joined on 12-01-2007
    • Greater Boston
    • Posts 154

    Re: SQL QUERY TO PUT THE DATA FROM ALL THE TABLES INTO ONE

    I think what you're looking for is a view

     

    create view myview as

    select * from personal1
    union
    select * from personal2

    etc 

     go

  • 06-05-2008 1:37 PM In reply to

    Re: SQL QUERY TO PUT THE DATA FROM ALL THE TABLES INTO ONE

    Yes that's correct using UNION statement but I recomend you to use UNIOL ALL

    SELECT * FROM T1

    UNION ALL

    SELECT * FROM T2

    ......

    UNION ALL

    SELECT * FROM T56

  • 06-05-2008 5:13 PM In reply to

    • aprato
    • Top 10 Contributor
    • Joined on 12-01-2007
    • Greater Boston
    • Posts 154

    Re: SQL QUERY TO PUT THE DATA FROM ALL THE TABLES INTO ONE

     

    Actually, it really depends on whether duplicates are acceptable in the result of the view.

     

    UNION = filters out duplicates

    UNION ALL = does not filter out duplicates

  • 06-13-2008 12:19 PM In reply to

    Re: SQL QUERY TO PUT THE DATA FROM ALL THE TABLES INTO ONE

    Why would you have 56 tables all with the same structure? Different client's info or poor design? Post the DDL of one of your tables and we could come up with the proper query fairly quickly. And, do you truly want a view of all the data or an actual table containing all the data?

  • 06-18-2008 4:46 AM In reply to

    • aami83
    • Top 100 Contributor
    • Joined on 04-16-2008
    • Posts 2

    Re: SQL QUERY TO PUT THE DATA FROM ALL THE TABLES INTO ONE

    hi thank you so much guys for your email and sorry for late replying actually i am telecom engineer and i have 56 different tables for 56 different BSC i have linked all bsc,s MS excel tables in MS ACCESS and then with the help of UNION commad i can see data for all the 56 tables in one table and can export to one excel sheet  thank u so much for sending me UNION command my database is working fine thanks u brothers have  a nice day

    bye

    aami

Page 1 of 1 (6 items)