Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Into Query???

Status
Not open for further replies.

calihiker

Technical User
Joined
Jun 13, 2003
Messages
96
Location
US
Hi, I have a text file that contains MySQL statements for creating a table and inserting values into it. I am trying to figure out how to use the statments in an access query for the easiest way to import all the data into a access table. Is there an easy way to change the syntax to be able to use this in Access?

Here is the code for the table and the data insert into statements...

CREATE TABLE shop_cart (
sessionid varchar(100) NOT NULL,
date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
cart text NOT NULL,
name varchar(100),
sname varchar(100),
address1 varchar(100),
saddress1 varchar(100),
address2 varchar(100),
saddress2 varchar(100),
city varchar(100),
scity varchar(100),
state varchar(100),
sstate varchar(100),
postalcode varchar(100),
spostalcode varchar(100),
country varchar(100),
scountry varchar(100),
phone varchar(100),
sphone varchar(100),
fax varchar(100),
sfax varchar(100),
email varchar(100),
comments text,
status varchar(40) NOT NULL,
KEY sessionid (sessionid)
);

#
# Dumping data for table 'shop_cart'
#

INSERT INTO shop_cart VALUES( '1765986', '2001-07-09 15:55:46', '1;35;TurboCAD v7 Professional Version;399.00;1;33;TurboCAD v7 Standard Version;99.00;', '', '', '', '', '', '', '', '', 'WY', 'WY', '', '', 'US', 'US', '', '', '', '', '', '', 'complete');
INSERT INTO shop_cart VALUES( '7956868', '2001-12-04 03:31:46', '1;121;SolidMech Upgrade (3.3)<br>(CD Version);50.00;0;', 'HENRY J KOOISTRA', 'HENRY J KOOISTRA', '8815 GLEN LN', '8815 GLEN LN', '', '', 'TULSA', 'TULSA', 'OK', 'OK', '74131', '74131', 'US', 'US', '(918) 270-9767', '(918) 270-9767', '(918) 270-9330', '(918) 270-9330', 'hank.k@lmco.com', '', 'complete');
INSERT INTO shop_cart VALUES( '4381350', '2002-01-11 06:41:11', '1;121;SolidMech Upgrade (3.3)<br>(CD Version);50.00;0;', 'Arthur Keigler', 'Arthur Keigler', '20 Pine Plain Road', '20 Pine Plain Road', '', '', 'Wellesley', 'Wellesley', 'MA', 'MA', '02481', '02481', 'US', 'US', '781 910 5760', '781 910 5760', '781 239 9745', '781 239 9745', 'akeigler@mediaone.net', '', 'complete');

Any help would be greatly appreciated, I tried figuring out how to use the code, but I couldn't. Now I am stuck with text-to-columns the data in excel and that alone causes alot of problems because the delimiter character, the comma, is in some of the string/fields and is seperating alot of the fields that need to kept together???

Thanks,
Andres
 
If the data is already in Excel then probably the simplest way is to insert a row at the top of the worksheet and type in the column names (if that's not already there) and then use access to import the XLS as a table. Access will fire up a wizard where you can define headings, data types, etc. You can then either append the records from your imported table to &quot;shop_cart&quot; or you can simply rename the imported table to &quot;shop_cart&quot;.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top