Syntax error with CREATE TABLE
-
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.
-
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.
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.
-
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.
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
-
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.
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. -
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.Thanks.