Share this Page URL

Chapter 11. Advanced Query Techniques > Using SQL for Data Definition - Pg. 457

Advanced Query Techniques 457 The SELECT INTO Statement Whereas the INSERT INTO statement inserts data into an existing table, the SELECT INTO state- ment inserts data into a new table. The syntax looks like this: SELECT column1 [,column2 [,...]] INTO new-table FROM table-list [WHERE where-clause] [ORDER BY orderby-clause] The WHERE clause is used to determine which rows in the source table are inserted into the desti- nation table. The ORDER BY clause is used to designate the order of the rows in the destination table. Here's an example: SELECT tblClients.ClientID, tblClients.CompanyName, tblClients.ContactFirstName, tblClients.ContactLastName, tblClients.ContactTitle, tblClients.DefaultRate INTO tblCheapClients FROM tblClients WHERE tblClients.DefaultRate)<=125 This statement inserts data from the selected fields in the tblClients table into a new table called tblCheapClients. Only the clients whose DefaultRate field is less than or equal to 125 are inserted. Using SQL for Data Definition Access 2003 offers two methods of programmatically defining and modifying objects. You can use