Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Thanks for the other suggestions. While I was waiting I wrote some VBA code to do it. It's not perfect, but did the job for me.</p> <pre><code>Option Compare Database Public Function TableCreateDDL(TableDef As TableDef) As String Dim fldDef As Field Dim FieldIndex As Integer Dim fldName As String, fldDataInfo As String Dim DDL As String Dim TableName As String TableName = TableDef.Name TableName = Replace(TableName, " ", "_") DDL = "create table " &amp; TableName &amp; "(" &amp; vbCrLf With TableDef For FieldIndex = 0 To .Fields.Count - 1 Set fldDef = .Fields(FieldIndex) With fldDef fldName = .Name fldName = Replace(fldName, " ", "_") Select Case .Type Case dbBoolean fldDataInfo = "nvarchar2" Case dbByte fldDataInfo = "number" Case dbInteger fldDataInfo = "number" Case dbLong fldDataInfo = "number" Case dbCurrency fldDataInfo = "number" Case dbSingle fldDataInfo = "number" Case dbDouble fldDataInfo = "number" Case dbDate fldDataInfo = "date" Case dbText fldDataInfo = "nvarchar2(" &amp; Format$(.Size) &amp; ")" Case dbLongBinary fldDataInfo = "****" Case dbMemo fldDataInfo = "****" Case dbGUID fldDataInfo = "nvarchar2(16)" End Select End With If FieldIndex &gt; 0 Then DDL = DDL &amp; ", " &amp; vbCrLf End If DDL = DDL &amp; " " &amp; fldName &amp; " " &amp; fldDataInfo Next FieldIndex End With DDL = DDL &amp; ");" TableCreateDDL = DDL End Function Sub ExportAllTableCreateDDL() Dim lTbl As Long Dim dBase As Database Dim Handle As Integer Set dBase = CurrentDb Handle = FreeFile Open "c:\export\TableCreateDDL.txt" For Output Access Write As #Handle For lTbl = 0 To dBase.TableDefs.Count - 1 'If the table name is a temporary or system table then ignore it If Left(dBase.TableDefs(lTbl).Name, 1) = "~" Or _ Left(dBase.TableDefs(lTbl).Name, 4) = "MSYS" Then '~ indicates a temporary table 'MSYS indicates a system level table Else Print #Handle, TableCreateDDL(dBase.TableDefs(lTbl)) End If Next lTbl Close Handle Set dBase = Nothing End Sub </code></pre> <p>I never claimed to be VB programmer.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload