2
votes

Good Morning,

Objective: I am working on trying to add new columns to a SSAS Tabular Model table. With a long-term aim to programmaticly made large-batch changes when needed.

Resources I've found: https://docs.microsoft.com/en-us/sql/analysis-services/tabular-models-scripting-language-commands/create-command-tmsl

This one gives the template I've been following but seems to not work.

What I have tried so far:

{
  "create": {  
    "parentObject": {  
      "database": "TabularModel_1_dev"
      , "table": "TableABC"
    }, 
    "columns": [
        {
        "name":  "New Column"
        , "dataType": "string"
        , "sourceColumn": "Column from SQL Source"
        }
    ]   
  }
}

This first one is the most true to the example but returns the following error:

"The JSON DDL request failed with the following error: Unrecognized JSON property: columns. Check path 'create.columns', line 7, position 15.."

Attempt Two:

{
  "create": {  
    "parentObject": {  
      "database": "TabularModel_1_dev"
      , "table": "TableABC"
    }, 
    "table": {
    "name": "Item Details by Branch",
    "columns": [
        {
        "name":  "New Column"
        , "dataType": "string"
        , "sourceColumn": "New Column"
        }
    ]
    }
  }
}

Adding table within the child list returns error too;

"...Cannot execute the Create command: the specified parent object cannot have a child object of type Table.." 

Omitting the table within the parentObject is unsuccessful as well.

1

1 Answers

1
votes

I know it's been three years since the post, but I too was attempting the same thing and stumbled across this post in my quest. I ended up reaching out to microsoft and was told that the Add Column example they gave in their documentation was a "doc bug". In fact, you can't add just a column, you have to feed it an entire table definition via createOrReplace.

SSAS Error Creating Column with TMSL