how to convert result of an select sql query into a new table in ms access

前端 未结 5 1615
鱼传尺愫
鱼传尺愫 2020-12-31 09:27

how to convert result of an select sql query into a new table in msaccess ?

相关标签:
5条回答
  • 2020-12-31 09:57

    If you want to do it through the user interface, you can also:

    A) Create and test the select query. Save it.

    B) Create a make table query. When asked what tables to show, select the query tab and your saved query.

    C) Tell it the name of the table you want to create.

    D) Go make coffee (depending on taste and size of table)

    0 讨论(0)
  • 2020-12-31 10:07

    First, create a table with the required keys, constraints, domain checking, references, etc. Then use an INSERT INTO..SELECT construct to populate it.

    Do not be tempted by SELECT..INTO..FROM constructs. The resulting table will have no keys, therefore will not actually be a table at all. Better to start with a proper table then add the data e.g. it will be easier to trap bad data.

    For an example of how things can go wrong with an SELECT..INTO clause: it can result in a column that includes the NULL value and while after the event you can change the column to NOT NULL the engine will not replace the NULLs, therefore you will end up with a NOT NULL column containing NULLs!

    Also consider creating a 'viewed' table e.g. using CREATE VIEW SQL DDL rather than a base table.

    0 讨论(0)
  • 2020-12-31 10:07
    Select *
    Into newtable
    From somequery
    
    0 讨论(0)
  • 2020-12-31 10:11

    Like so:

    SELECT    *
    INTO      NewTable
    FROM      OldTable
    
    0 讨论(0)
  • 2020-12-31 10:19

    You can use sub queries

    SELECT a,b,c INTO NewTable 
    FROM (SELECT a,b,c
    FROM TheTable
    WHERE a Is Null)
    
    0 讨论(0)
提交回复
热议问题