I'm trying to migrate an Access database to a PostgreSQL DB, and lots of table names or column names have space or number, for instance, table name: "test history" and "123 people", and column name: "test history". I'm keeping getting SQL syntax errors because of these spaces and numbers.
'create tables in PostgreSQL database
Dim tdf As DAO.TableDef
For Each tdf In CurrentDb.TableDefs
If Left(tdf.Name, 4) <> "MSys" Then
Dim strCreateTable As String
strCreateTable = "CREATE TABLE " & tdf.Name & " ("
For Each fld In tdf.fields
strCreateTable = strCreateTable & fld.Name & " " & GetPostgreSQLDataType(fld.Type) & ","
Next fld
strCreateTable = Left(strCreateTable, Len(strCreateTable) - 1) & ")"
'MsgBox strCreateTable
cnn.Execute strCreateTable
End If
Next tdf
Just wondering if there is a way to transfer the output of table name and column name to a string.