t-sql to create table

message from tobbe on 26 May 2004
Hi

How do I create a table in access whit a t-sql script? Im accessing the
strSql = " CREATE TABLE language (pkid COUNTER not null, name Text(50)) "
objAdo.ExecQuery (strSql)

But it does not work.

Best Regards
Tobbe
 
Alex Dybenko replied to tobbe on 26 May 2004
probably you dont have enough permissions to create table? what error
"CREATE TABLE language (pkid int not null, name nvarchar(50))"
 
tobbe replied to Alex Dybenko on 27 May 2004
Thanks for your answer!

Thats the problem, im not using SQL Server i need to create the table in the
access database. The error i get is something like (have swedish access)
"Invalid syntax in create table". So im guessing that its possible to create
a table in Access through t-sql. The question is how dos the syntax look
like!? Havnt been able to find any help googling or altavistin ;)

"Alex Dybenko" <Alex@No.cemi.SPAM.rssi.Please.ru> skrev i meddelandet
news:%234bCzozQEHA.2572@TK2MSFTNGP12.phx.gbl...
 
scott parmelee replied to tobbe on 27 May 2004
Hi,
t-sql (transact-sql) is used only in SQL Server (MS or Sybase)
although ms access sql is similar. The access online help has some
examples of using Microsoft Jet SQL to create tables and indexes. For
example:

This example creates a new table called MyTable with two text fields,
a Date/Time field, and a unique index made up of all three fields.

Sub CreateTableX2()
Dim dbs As Database

' Modify this line to include the path to Northwind
' on your computer.

Set dbs = OpenDatabase("Northwind.mdb")

' Create a table with three fields and a unique
' index made up of all three fields.

dbs.Execute "CREATE TABLE MyTable " _
& "(FirstName CHAR, LastName CHAR, " _
& "DateOfBirth DATETIME, " _
& "CONSTRAINT MyTableConstraint UNIQUE " _
& "(FirstName, LastName, DateOfBirth));"
dbs.Close
End Sub

hth,
Scott
 

Archived message: t-sql to create table (Microsoft Access Forms)