Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > CREATE TABLE with a DEFAULT for Microsoft Access

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-22-04, 16:16
dwulff dwulff is offline
Registered User
 
Join Date: Jun 2004
Posts: 4
Question CREATE TABLE with a DEFAULT for Microsoft Access

I'm missing SQL Server already.

This doesn't work with a Microsoft Access database. The DEFAULT is causing a syntax exception. Trying to find any help with Google has prooved very frustrating and given me no leads, so do any of you know how it is done in a CREATE TABLE statement? (i.e. not seperately).

Code:
CREATE TABLE [MyTable] ( [MyField] VARCHAR(50) DEFAULT "" )

Thanks for reading,

- David

(btw, I posted this in the general SQL forum as there didn't seem to be one for non-application-type MS Access questions. Hope that was right.)

Last edited by dwulff : 06-22-04 at 16:21.
Reply With Quote
  #2 (permalink)  
Old 07-02-04, 10:39
dmmac dmmac is offline
Registered User
 
Join Date: Aug 2003
Location: Massachusetts, USA
Posts: 106
When you use the Table Design within Access there is Default Value property for a column.
By the way there is a Microsoft Access section with dbforums.
Reply With Quote
  #3 (permalink)  
Old 07-02-04, 10:54
dwulff dwulff is offline
Registered User
 
Join Date: Jun 2004
Posts: 4
I know about that, I want to set it using an SQL statement though. I am creating the database tables through script not using Access itself.

I mentioned why I didn't use the Microsoft Access forum in my edit. I looked at the messages that were on the first few pages and they seemed to all be application-orientated.

Thanks for your reply,

- David
Reply With Quote
  #4 (permalink)  
Old 07-02-04, 11:19
dmmac dmmac is offline
Registered User
 
Join Date: Aug 2003
Location: Massachusetts, USA
Posts: 106
Ok, but it is just a suggestion to maybe have your question duplicated in the MS Access (you never know who might be popping in there to view stuff).

Also, have you looked at the Access documentation there is a section about Jet SQL Reference (not sure if that is what you need to reference)...although it looks as though there isn't a mention of DEFAULT. I agree with you when you 'downgrade' from a DB engine that has everything to something that lacks, it is frustrating.

Good luck.....
Reply With Quote
  #5 (permalink)  
Old 07-25-04, 02:38
tonyngo tonyngo is offline
Registered User
 
Join Date: Jul 2004
Posts: 1
You are Close

CREATE TABLE [MyTable] (
MyField Text(50) DEFAULT Hello World,
MyID Integer NOT NULL DEFAULT 1
)

Sorry for pulling a Hello world stuff on ya but that should work.
Reply With Quote
  #6 (permalink)  
Old 07-25-04, 08:25
dwulff dwulff is offline
Registered User
 
Join Date: Jun 2004
Posts: 4
I tried running that SQL in MS Access itself and got the same error I have been seeing with other attempts:

------------------------------------------------
Microsoft Access
------------------------------------------------
Syntax error in CREATE TABLE statement.
------------------------------------------------
OK Help
------------------------------------------------

It then selects the CREATE keyword in the SQL window.

I am using Access 2002/XP for this, should I be using something else?
Reply With Quote
  #7 (permalink)  
Old 07-25-04, 11:58
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 9,573
Just an observation, but MS-Access is a client side program. By default, it ships with the Microsoft-Jet database engine. If you have MS-Access 2002, you have MSDE on the CD, which is a slightly scaled down version of MS-SQL.

It might be worthwhile for you to install MSDE and use that as your database engine. It would put you on much more familiar ground!

-PatP
Reply With Quote
  #8 (permalink)  
Old 07-25-04, 15:52
dwulff dwulff is offline
Registered User
 
Join Date: Jun 2004
Posts: 4
Thanks Pat, but it's not for that sort of use. The product gets installed on web servers that don't have SQL Server or MSDE available to them. (if it does, it would use them anyway).
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On