Macro to generate DDL output: unable to enable the 'create schema [xx] auth.. ' statement in the output?

Hi all,

I am building a modeling pipeline where the end product is a generated DDL. Almost finished with that (casetalk > er/studio > sql server) pipeline..

The last bit is generating the schema SQL output:
CREATE SCHEMA [ia] AUTHORIZATION dbo
go

I am unable to find the boolean that enables that line :-(

Function CreateDDLForAzureSQL(ByRef MyModel As Model, ByVal MyFilename As String)
Dim DDLObj As DDLGeneration
MyDDLFile = Replace(MyFilename, ".dm1", "_AzureSQL_DDL.sql")

Const SINGLE_FILE As Integer = 1
Const ODBC As Integer = 2
Const DIRECT_CONNECTION As Integer = 3
Const MULTIPLE_FILES As Integer = 4

Set DDLObj = MyModel.DDLGenerationObject
DDLObj.GenAllOwnerNames = True
DDLObj.GeneratePKByAlterStatement=True
DDLObj.SupplyPKConstraintName = True
DDLObj.GenerateDatabaseMethod = SINGLE_FILE
DDLObj.GenerateAllEntities
DDLObj.GenerateDefaults = True
DDLObj.GenForceBrackets = True
DDLObj.GenerateTableCheckConstraints = True
DDLObj.GenModelPreSQL = True
DDLObj.GenModelPostSQL = True
DDLObj.GenAllOwnerNames = True
DDLObj.CreateNewDatabase = True
DDLObj.GenerateViews = True
DDLObj.CreationScriptFilePath = MyDDLFile
DDLObj.GenerateDDL
CreateDDLForAzureSQL = MyDDLFile
End Function

Is there anyone out there that knows the DDLGenerationObject boolean?
Gr. and thanks a lot in advance!
Roy

  • Sometimes there is a more simpler way.. I've fixed it by adding the schema creation code to the PreSQL code, like so:

    Dim MyPreSQL As String
    MyPreSQL = "/* SCHEMA ADDED BY DATAMODELING PIPELINE: "+dlg.Owner+"  */" + vbCrLf
    MyPreSQL = MyPreSQL + "CREATE SCHEMA ["+dlg.Owner+"] AUTHORIZATION dbo" + vbCrLf
    MyPreSQL = MyPreSQL + "go" + vbCrLf
    MyModel.PreSQL = MyPreSQL
    
    ' And somewhere further down...
    
    Set DDLObj = MyModel.DDLGenerationObject
    			...
    			DDLObj.GenModelPreSQL = True
    		    DDLObj.GenModelPostSQL = True
    		    ...
    DDLObj.GenerateDDL

    I know the code can be much better.. but this works for now. Hope it will help someone with the same questions ;-)