Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Syntax error with CREATE TABLE

Syntax error with CREATE TABLE

Scheduled Pinned Locked Moved Database
databasehelpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    IrishSonic
    wrote on last edited by
    #1

    Hiya am getting a syntax error on using CREATE TABLE in SQL and an Access database: // open the database database.Open( NULL,false,false,sDsn ); database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4) OfficeName TEXT(10) ) "); Does anyone know what is wrong with the ExecuteSQL line.. Thanks grahamoj.

    I 1 Reply Last reply
    0
    • I IrishSonic

      Hiya am getting a syntax error on using CREATE TABLE in SQL and an Access database: // open the database database.Open( NULL,false,false,sDsn ); database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4) OfficeName TEXT(10) ) "); Does anyone know what is wrong with the ExecuteSQL line.. Thanks grahamoj.

      I Offline
      I Offline
      IrishSonic
      wrote on last edited by
      #2

      Hiya again, I found out my problem. Missing comma i.e database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4),OfficeName TEXT(10) ) "); So now what I need to be able to do is make the text field 600 chars. So tried these: database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4) OfficeName TEXT(600) ) "); and database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4) OfficeName MEMO(600) ) "); but it won't create the table because text fields are too long.. any ideas on how to do this?? grahamoj.

      K D 2 Replies Last reply
      0
      • I IrishSonic

        Hiya again, I found out my problem. Missing comma i.e database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4),OfficeName TEXT(10) ) "); So now what I need to be able to do is make the text field 600 chars. So tried these: database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4) OfficeName TEXT(600) ) "); and database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4) OfficeName MEMO(600) ) "); but it won't create the table because text fields are too long.. any ideas on how to do this?? grahamoj.

        K Offline
        K Offline
        karl_w
        wrote on last edited by
        #3

        For SQL-Server the maximum length for TEXT is 2,147,483,647 (and even VARCHAR can store up to 8000 characters), so I don't think 600 should be the problem. Maybe it's just the missing comma again? --edit-- BTW: For 600 characters you shouldn't use TEXT but VARCHAR because of better performance. TEXT is designed for storing large textfiles, so in the table there is only stored a pointer to the actual data. --edit-- -- karl

        1 Reply Last reply
        0
        • I IrishSonic

          Hiya again, I found out my problem. Missing comma i.e database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4),OfficeName TEXT(10) ) "); So now what I need to be able to do is make the text field 600 chars. So tried these: database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4) OfficeName TEXT(600) ) "); and database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4) OfficeName MEMO(600) ) "); but it won't create the table because text fields are too long.. any ideas on how to do this?? grahamoj.

          D Offline
          D Offline
          David Salter
          wrote on last edited by
          #4

          grahamoj wrote: database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4) OfficeName MEMO(600) ) "); Don't specify a length for a memo, i.e. use: database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4), OfficeName MEMO ) "); Dave.

          I 1 Reply Last reply
          0
          • D David Salter

            grahamoj wrote: database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4) OfficeName MEMO(600) ) "); Don't specify a length for a memo, i.e. use: database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4), OfficeName MEMO ) "); Dave.

            I Offline
            I Offline
            IrishSonic
            wrote on last edited by
            #5

            Thanks.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups