g
Printer Friendly Version

editor  
BellaOnline's ASP Editor
 

Create a Table with SQL Syntax

Need to create a table to put data in? It's very easy to put together SQL Syntax to build the table to store your newsletter members, poll votes, or more.

To start with, get a connection to your databse using ODBC, Access, PowerBuilder, or whatever other tool you use. Open up a SQL window so you can submit a SQL command to your database.

Now for the syntax. The general syntax to create a table is

CREATE TABLE tablename (field1 type1, field2 type2, field3 type3 ...);

So let's say you want to create a table called MEMBERS which holds your newsletter members in it. The fields you are tracking are memb_email, memb_date to know when each person joined you. You would say:

CREATE TABLE members (memb_email varchar(50), memb_date datetime);

The most commonly used field types are:

int
char(#)
varchar(#)
datetime

The char field is best used when you are always going to have a set number of letters. So this is good to use for char(1) if you are doing a nl_type of H for HTML and T for text. The varchar field is best used when the character lengths will always be different, such as when you are taking in email addresses of varying lengths.

Introduction to ASP Ebook

Download this ebook to get everything you need to know about learning ASP - from a step by step tutorial to function lists, sample code, common errors and solutions, and much more! 101 pages.

ASP Site @ BellaOnline
View This Article in Regular Layout

Content copyright © 2013 by Lisa Shea. All rights reserved.
This content was written by Lisa Shea. If you wish to use this content in any manner, you need written permission. Contact Lisa Shea for details.



| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2014 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor