LOCAL oDb as SQLDMO.Database, oSvr as SQLDMO.sqlserver,; oIndex as SQLDMO.index * create a database oDb = NEWOBJECT('sqldmo.database') oDb.Name = 'testnumber2' * create a database file oDbFile = NEWOBJECT('sqldmo.dbfile') oDbFile.Name = 'testnumber1' oDbFile.PhysicalName = 'c:\sqldata\testnumber2.mdb' oDbFile.Size = 10 * add the file to the DB file group oDb.FileGroups('primary').DBFiles.Add(oDbFile) * create a server object and add the new DB to it oSvr = NEWOBJECT('sqldmo.sqlserver') oSvr.LoginSecure = .t. oSvr.Connect('(local)') oSvr.Databases.Add(oDb) * create a table oTable1 = NEWOBJECT('sqldmo.table') oTable1.Name = 'tbl_parent' * add columns to the table oCol1 = NEWOBJECT('sqldmo.column') oCol1.Name = 'crandomname' oCol1.Datatype = 'char' oCol1.Length = 10 oTable1.Columns.Add(oCol1) * add the table to the database oDb.Tables.Add(oTable1) * cannot reuse the table object unless you release it * so we'll create a new one oTable2 = NEWOBJECT('sqldmo.table') oTable2.Name = 'tbl_child' oCol1 = NEWOBJECT('sqldmo.column') oCol1.Name = 'crandomname' oCol1.Datatype = 'char' oCol1.Length = 10 oTable2.Columns.Add(oCol1) * add the table to the database oDb.Tables.Add(oTable2) * create an index oIndex = NEWOBJECT('sqldmo.index') oIndex.Name = "cRandomName" oIndex.IndexedColumns = "crandomname" oTable1.Indexes.Add(oIndex)DMO is covered extensively in the BOL, check it out.