Connecting Tech Pros Worldwide Help | Site Map

How to create non-unique index with DDL?

  #1  
Old November 12th, 2005, 07:40 PM
deko
Guest
 
Posts: n/a
I'd like to use DDL (Data Definition Language) rather than VBA code to create a
new table. The below DDL statement creates the table very nicely:

CREATE TABLE tblTx03 (Subject Text (100), Entity_ID Long, TxDate Date, Tx_ID
AutoIncrement Constraint PrimaryKey PRIMARY KEY);

The problem is I want a non-unique index on TxDate - can this be done in the
same statement?

Or do I need to run a separate statement to add the non-unique index?

CREATE INDEX idxTxDate ON tblTx03 ( TxDate ASC );

Thanks in advance.


  #2  
Old November 12th, 2005, 07:42 PM
Dimitri Furman
Guest
 
Posts: n/a

re: How to create non-unique index with DDL?


On Jan 29 2004, 11:48 am, "deko" <dje422@hotmail.com> wrote in
news:GPaSb.7492$Mv1.5140@newssvr29.news.prodigy.co m:
[color=blue]
> I'd like to use DDL (Data Definition Language) rather than VBA code to
> create a new table. The below DDL statement creates the table very
> nicely:
>
> CREATE TABLE tblTx03 (Subject Text (100), Entity_ID Long, TxDate
> Date, Tx_ID
> AutoIncrement Constraint PrimaryKey PRIMARY KEY);
>
> The problem is I want a non-unique index on TxDate - can this be done
> in the same statement?[/color]

According to Help, only unique or primary key indexes can be specified in
the CREATE TABLE statement in Jet, both 3.5 and 4.0.
[color=blue]
> Or do I need to run a separate statement to add the non-unique index?
>
> CREATE INDEX idxTxDate ON tblTx03 ( TxDate ASC );[/color]

This will do it. You may want to wrap both statements in a transaction.

--
(remove a 9 to reply by email)
  #3  
Old November 12th, 2005, 07:42 PM
deko
Guest
 
Posts: n/a

re: How to create non-unique index with DDL?


10-4

I discovered Microsoft Knowledge Base Article 180841, which is also helpful...

"Dimitri Furman" <dfurman@cloud99.net> wrote in message
news:Xns947FD0799180Ddfurmancloud99@127.0.0.1...[color=blue]
> On Jan 29 2004, 11:48 am, "deko" <dje422@hotmail.com> wrote in
> news:GPaSb.7492$Mv1.5140@newssvr29.news.prodigy.co m:
>[color=green]
> > I'd like to use DDL (Data Definition Language) rather than VBA code to
> > create a new table. The below DDL statement creates the table very
> > nicely:
> >
> > CREATE TABLE tblTx03 (Subject Text (100), Entity_ID Long, TxDate
> > Date, Tx_ID
> > AutoIncrement Constraint PrimaryKey PRIMARY KEY);
> >
> > The problem is I want a non-unique index on TxDate - can this be done
> > in the same statement?[/color]
>
> According to Help, only unique or primary key indexes can be specified in
> the CREATE TABLE statement in Jet, both 3.5 and 4.0.
>[color=green]
> > Or do I need to run a separate statement to add the non-unique index?
> >
> > CREATE INDEX idxTxDate ON tblTx03 ( TxDate ASC );[/color]
>
> This will do it. You may want to wrap both statements in a transaction.
>
> --
> (remove a 9 to reply by email)[/color]


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regarding DB2 700 exam. rohit answers 9 October 16th, 2007 07:59 PM
are ado questions allowed here? MP answers 19 December 4th, 2005 02:55 AM
altering a table to set serial function Prabu Subroto answers 12 November 23rd, 2005 01:30 AM
Creation of Indexes in UDB for LUW alex.mcshane@btinternet.com answers 2 November 12th, 2005 11:47 AM
Creating Primary key with ODBC RS200Phil answers 7 October 19th, 2005 09:15 AM