Customize Create Table syntax

Comments

3 comments

  • Avatar
    Andreas Koppenhoefer

    Hi,

     

    I'm not entirely sure what you are trying to do here, but you can always customize your FET.

    Go to Forward Engineering and open the editor.

    Open the 'Create Entity' template and search for the place where the closing bracket is created (for sql server 2012 it should be line 326)

     

    Add something similar to this:


    @if(Equal(Property("Entity.Physical.DistributionType"), "REPLICATE"))
    {
    Set("DisType","REPLICATE")
    }
    @elseif(Equal(Property("Entity.Physical.DistributionType") "MyOtherType"))
    {
    /* Get Information about your Column from your Properties */
    /* Set DisType to the appropriate string */
    }
    "\n\tWITH(CLUSTERED COLUMN INDEX, DISTRIBUTION = " Value("DisType") ");"

     

    0
    Comment actions Permalink
  • Avatar
    Jeremy Busselman

    This is GREAT!  It is exactly what I'm looking for.  Unfortunately I'm new to the syntax for coding the template, so I'm hoping you can set me on the right path.  If the DistributionType = "DISTRIBUTE" then I need to get the Attribute Name where a custom field called "DistributionKey" is set to TRUE.  Is this as simple as doing some kind of Select AttributeName from Attributes where Table = 'AAATest' and DistributionKey is TRUE? or do I need to read through each attribute until I hit the one that is true?

    I'm researching now, but if you are able to provide direction for this last piece, it would be awesome!

    Thanks,
    JB

    0
    Comment actions Permalink
  • Avatar
    Jeremy Busselman

    I figured it out for others to reference

     

    ForEachOwnee("Attribute")
     {
     @If(Equal(Property("Attribute.Physical.Distribution Key"),"-1 {True}"))
     {
      Set("DisType","HASH(["Property("Physical_Name")"])")
     }
     }

    1
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk