-
SQL in MSACCESS
Hi All,
Does anyone know how to execute multiple 'CREATE TABLE' statements etc. within
and MSAccess database? I've tried using an 'Add table' query but it only
allows one table to be add at a time.
I basically need to generate the whole database from a sql script.
Thanks,
Kent
-
Re: SQL in MSACCESS
"Kent" <kentcb@hotmail.com> wrote in message <news:3aa43b84$1@news.devx.com>...
> Hi All,
>
> Does anyone know how to execute multiple 'CREATE TABLE' statements etc. within
> and MSAccess database? I've tried using an 'Add table' query but it only
> allows one table to be add at a time.
>
> I basically need to generate the whole database from a sql script.
How are the statements separated within the script? The best case would
be blank lines or semicolons and cr/lf. Are there text values being
inserted into the tables, and if so, can these values also contain
semicolons? In short, you might be looking at writing a parser, but if
so, it should at worst need to be aware of the syntax for text literals
and not all of Access SQL syntax. Here's an example or two:
The best case scenario:
create table Article (MessageID text, Head memo, Body memo,
constraint PrimaryKey primary key (MessageID));
create table Newsgroup (Group text, Description memo,
constraint PrimaryKey primary key (Group));
create table ArticleGroup (Group text, MessageID text, Sequence long,
constraint PrimaryKey primary key (Group, MessageID),
constraint Ordering unique (Group, Sequence),
constraint MessageID foreign key (MessageID) references Article (MessageID),
constraint Group foreign key (Group) references Newsgroup (Group));
insert into Article (MessageID, Head, Body)
values ('fee; fie; foe; fum', 'x = ''fee; fie; foe; fum''',
'I smell the blood of an Englishman');
The worst case scenario:
create table Article (MessageID text, Head memo, Body memo,
constraint PrimaryKey primary key (MessageID)); insert into Article
(MessageID, Head, Body) values ('fee; fie; foe; fum',
'x = ''fee; fie; foe; fum''', 'I smell the blood of an Englishman');
--
Joe Foster <mailto:jfoster@ricochet.net> Space Cooties! <http://www.xenu.net/>
WARNING: I cannot be held responsible for the above They're coming to
because my cats have apparently learned to type. take me away, ha ha!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks