SQL CREATE TABLE Syntax error, please help..

Results 1 to 5 of 5

Thread: SQL CREATE TABLE Syntax error, please help..

  1. #1
    Tom Levesque Guest

    Default SQL CREATE TABLE Syntax error, please help..

    Here is the variable which I feed into Execute() to make a table. I get a CREATE TABLE Syntax error when I run this, why?<BR><BR>sql = "CREATE TABLE threads ( topicid long integer primary key, "<BR>sql = sql & "topic varchar not null, postdate Date not null, " <BR>sql = sql & "posterid varchar not null, section varchar not null, "<BR>sql = sql & "replynum long integer not null );"<BR><BR>On a related note, I&#039m still a bit confused about foriegn and primary kets. Lets say I have a table, "registeredUsers" whose "id" column is a primary key for "registeredUsers" but is also used in the table above in terms of referring the number in "posterid" to the "id" column in "registeredUsers" such that a simple number in one table refers to a first and last name and callsign in another table. My question here is: which one do I make the foriegn key, which one the primary key and why?<BR><BR>Also please figure out what my syntax error was. :)

  2. #2
    Garth Guest

    Default RE: SQL CREATE TABLE Syntax error, please help..

    CREATE TABLE Threads <BR>( <BR> TopicID int primary key, <BR> Topic varchar not null, <BR> PostDate datetime not null, <BR> PosterID varchar FOREIGN KEY REFERENCES RegisteredUsers(ID), <BR> Section varchar not null, <BR> ReplyNum int not null <BR>)<BR><BR>The primary key is the ID column RegisteredUsers and the foreign key is in Threads. I showed the syntax for creating the relationship above.<BR><BR>Garth<BR>www.SQLBook.com<BR><BR>

  3. #3
    Tom Levesque Guest

    Default Whatever you do, you deserve a raise

    THANK YOU That&#039s _EXACTLY_ what I wanted. I am checking out your website right now too hehe

  4. #4
    Tom Levesque Guest

    Default ONE MORE QUESTION regarding datetime

    OK, the "datetime" data type. . . I&#039ve never seen that. When inserting a value into this type of column, does it go like this? :<BR><BR>mm/dd/yyyy 11:59 pm &#039 normal time?<BR><BR>or like this:<BR><BR>mm/dd/yyyy 23:59 &#039 miltary time?<BR><BR>THANKS.

  5. #5
    Join Date
    Dec 1969

    Default RE: ONE MORE QUESTION regarding datetime

    Tom, in Win95 at least, it&#039s mm/dd/yyyy hh:mm:ss (AM/PM). Doesn&#039t seem to know about military time. Check your regional settings control panel.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts