SQL statement implementation, SQL Server 2000 and access copy the oldtable structure of the old table, or structure and content to the new table newtable
Both of them have been tried.CodeBoth databases (SQL Server 2000 and access) can pass through.
-- Copy the new table structure
Select *Into newtableFrom oldtable where 1 = 2
-- Copy the table structure and content to the new table
Select *Into newtableFrom oldtable
If you only need to combine some fields in the old table or previous table or the summarized content into a field, you can
-- Copy some fields in the table structure to the new table.
Select title, type, price, notes OKInto newtable2From titles where 1 = 2
-- Copy the table structure and content to the new table. You can select fields.
Select title, type, price, pub_id-price OKInto newtable2From titles
You can also copy the table structure (you can select some fields as the new table) and insert the content.
-- Copy some fields in the table structure to the new table.
Select title Y1, type Y2, price Y3Into yongfa365From titles where 1 = 2
-- Add data to the new table
Insert into yongfa365 (Y1, Y2, Y3) Select title, type, price from titles
In fact, we can see from the above example that no matter whether it is copying the table structure, content, or summary results, we can all go to a new table. Why? I think of it now, I can
(Select * from
Table) as a table, then there is an answer to this question: Since you can regard the selected result as a table, the table can be saved and directly saved as a real table, for later use.
You can remove the yellow font above and run the same code.