Posted By

qrist0ph on 06/13/08


Tagged

access DDL


Versions (?)

Access Tabellen Schema aus Data Dictionary erzeugen


 / Published in: Visual Basic
 

  1. Sub createTableSchemaFromDataDictionary()
  2. Dim dataDictionary As Recordset
  3. Dim sqlSchema
  4. sqlSchema = "Select table_name,field_name, datatype from DataDictionary"
  5. Set dataDictionary = CurrentDb.OpenRecordset(sqlSchema)
  6. 'durch alle datensätze des Data Dictionary loopen
  7. Do While Not dataDictionary.EOF
  8. 'neue tabelle erzeugen
  9. On Error Resume Next
  10. DoCmd.RunSQL "CREATE TABLE " & dataDictionary!table_name & " ([id] COUNTER CONSTRAINT ndxStaffID PRIMARY KEY)"
  11. 'neue spalte erzeugen
  12. DoCmd.RunSQL "ALTER TABLE " & dataDictionary!table_name & " ADD COLUMN [" & dataDictionary!field_name & "] " & dataDictionary!datatype & ";"
  13. dataDictionary.MoveNext
  14. Loop
  15. End Sub

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: qrist0ph on July 28, 2008

Erzeugt jedoch keine Beziehungen z.B für referentielle Integrität

You need to login to post a comment.