I want to use SQL code to Create a Table & Provide a Default Value for
Each Column.
Here is the code I am using:
CREATE TABLE customer
(First_Name char(50),
Last_Name char(50),
Address char(50) default 'Unknown',
City char(50) default 'Mumbai',
Country char(25),
Birth_Date date)
What can I do to make this work with MS Access?
Thanks!,
zufie 3 25756
On 23 Mar, 14:28, "zufie" <john.marru...@ illinois.govwro te:
I want to use SQL code to Create a Table & Provide a Default Value for
Each Column.
Here is the code I am using:
CREATE TABLE customer
(First_Name char(50),
Last_Name char(50),
Address char(50) default 'Unknown',
City char(50) default 'Mumbai',
Country char(25),
Birth_Date date)
What can I do to make this work with MS Access?
Thanks!,
zufie
TTBOMR one must use ALTER TABLE as in
"ALTER TABLE customer ALTER COLUMN FirstName SET DEFAULT 'Bubba'"
My own opinion is that when a default value is needed, it's best to
set this in the form or other user interface, or insert query.
In article <1174674510.412 904.62590
@y66g2000hsf.go oglegroups.com> , jo***********@i llinois.gov
says...
I want to use SQL code to Create a Table & Provide a Default Value for
Each Column.
Here is the code I am using:
CREATE TABLE customer
(First_Name char(50),
Last_Name char(50),
Address char(50) default 'Unknown',
City char(50) default 'Mumbai',
Country char(25),
Birth_Date date)
What can I do to make this work with MS Access?
Thanks!,
zufie
This is by way of example. You might want to look at SQL
Programming Style by Joe Celko for guidance on column names and
data types.
Notice that I was able to insert a record with 3 NOT NULL
columns missing. This was thanks to the default values.
Sub CreateTables()
With CurrentProject. AccessConnectio n
.Execute _
"CREATE TABLE customer" & _
" (First_Name VARCHAR(50)," & _
" Last_Name VARCHAR(50)," & _
" Mail_Address VARCHAR(50) DEFAULT Unknown," & _
" City_Name VARCHAR(50) DEFAULT Mumbai," & _
" Country_Name VARCHAR(25) DEFAULT Unknown," & _
" Birth_Date DATE," & _
" UNIQUE (Last_Name, First_Name, Birth_Date))"
.Execute _
"INSERT INTO customer" & _
" ( First_Name, Last_Name, Birth_Date )" & _
" VALUES ('Larry', 'Smith', #11/29/1985#);"
End With
End Sub
On Mar 24, 6:37 am, Mike Gramelspacher <grame...@psci. netwrote:
In article <1174674510.412 904.62590
@y66g2000hsf.go oglegroups.com> , john.marru...@i llinois.gov
says...
I want to use SQL code to Create a Table & Provide a Default Value for
Each Column.
Here is the code I am using:
CREATE TABLE customer
(First_Name char(50),
Last_Name char(50),
Address char(50) default 'Unknown',
City char(50) default 'Mumbai',
Country char(25),
Birth_Date date)
What can I do to make this work with MSAccess?
Thanks!,
zufie
This is by way of example. You might want to look at SQL
Programming Style by Joe Celko for guidance on column names and
data types.
Notice that I was able to insert a record with 3 NOT NULL
columns missing. This was thanks to the default values.
Sub CreateTables()
With CurrentProject. AccessConnectio n
.Execute _
"CREATE TABLE customer" & _
" (First_Name VARCHAR(50)," & _
" Last_Name VARCHAR(50)," & _
" Mail_Address VARCHAR(50) DEFAULT Unknown," & _
" City_Name VARCHAR(50) DEFAULT Mumbai," & _
" Country_Name VARCHAR(25) DEFAULT Unknown," & _
" Birth_Date DATE," & _
" UNIQUE (Last_Name, First_Name, Birth_Date))"
.Execute _
"INSERT INTO customer" & _
" ( First_Name, Last_Name, Birth_Date )" & _
" VALUES ('Larry', 'Smith', #11/29/1985#);"
End With
End Sub- Hide quoted text -
- Show quoted text -
I suppose my statement would make sense if I had used DDL like this:
..Execute _
"CREATE TABLE customer" & _
" (Customer_id IDENTITY (1,1) NOT NULL PRIMARY KEY, " & _
" First_Name VARCHAR(50) NOT NULL," & _
" Last_Name VARCHAR(50) NOT NULL," & _
" Mail_Address VARCHAR(50) DEFAULT Unknown NOT NULL," & _
" City_Name VARCHAR(50) DEFAULT Mumbai NOT NULL," & _
" Country_Name VARCHAR(25) DEFAULT France NOT NULL," & _
" Birth_Date DATE NOT NULL," & _
" UNIQUE (Last_Name, First_Name, Birth_Date))"
I guess you customers will always be persons and will never refuse to
disclose their birth date. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Glutinous |
last post by:
I've been studying this for hours, searching the www & usenet, and
still can't figure out why 'each' returns an array of four key/value
pairs, when it looks like just two pairs would suffice...
That is, it looks to me like
&
are the same, and also
& ,
so what's the point of duplicating them?
|
by: dawnunder |
last post by:
eg.
Someone fills out 3 fields. (There will be more but this is just to
give you an idea)
1. Country?
2. State?
3. City
I want this script to generate a web page and list the people by
|
by: Alicia |
last post by:
Does anyone know why I am getting a "Syntax error in Create Table
statement". I am using Microsoft Access SQL View to enter it. Any
other problems I may run into?
CREATE TABLE weeks
(
weekstart datetime not null primary key,
weekend datetime not null
)
|
by: Max |
last post by:
Hello everyone, and thank you in advance for all of your help!
I have a tblPrint table in Access 2002. Its structure is as follows:
tblPrint
------------------
Name, Text
Address1, Text
Address2, Text
City, Text
|
by: dog |
last post by:
I've seen plenty of articles on this topic but none of them have been
able to solve my problem.
I am working with an Access 97 database on an NT4.0 machine, which has
many Access reports.
I want my users to be able to select a report, click on a command
button on a form, which will then automatically create the report as a
pdf file and save it to the user's machine.
I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
| |
by: groupy |
last post by:
Hello all,
my question might be trivial but since my background isn't DB i'll dare
to ask it any way:
how to create a real (not virtual) table from view1 & view2 ni sql
server?
what should i do specificly in the sql server application & what is the
syntax for that?
|
by: Peter Nurse |
last post by:
For reasons that are not relevant (though I explain them below *), I
want, for all my users whatever privelige level, an SP which creates
and inserts into a temporary table and then another SP which reads and
drops the same temporary table.
My users are not able to create dbo tables (eg dbo.tblTest), but are
permitted to create tables under their own user (eg MyUser.tblTest). I
have found that I can achieve my aim by using code like...
|
by: TinaF |
last post by:
I want to set a default value in a table called "Quotes" for a field
called "Source."
The "Source" field uses a lookup table called "Source" which looks
like this:
Sourceabbrev Sourcename
BX-MI BUILDERS EXCHANGE MI
BX-OH BUILDERS EXCHANGE OH
CNS-MI CONSTRUCTION NEWS SERVICE MI
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |