Runing SSAS Tabular Processing Script (TMSL) from SSAS Database Engine

PANDEY Prashant 145 Reputation points
2024-09-24T11:15:03.1866667+00:00

Hello Experts,

In continuation of my previous question

https://learn.microsoft.com/en-us/answers/questions/2076521/processing-monthly-partition-from-sql-job-using-st?source=docs

We have SSAS Tabular model database and SSAS Database engine.

When trying to execute the TMSL script (mentioned in above question) by calling stored procedure or through SQL job(of type Transact SQL - TSQL) from SSAS Database engine giving error.

DECLARE @return_value int

EXEC @return_value = [dbo].[ProcessMonthlyPartition]

SELECT 'Return Value' = @return_value

GO

Msg 102, Level 15, State 1, Line 4

Incorrect syntax near '{'.

which is obvious as Database engine expecting any DDL syntax (select/update) .

Can you guys please help to know how the TMSL scripts can be called from SSAS database engine either by directly calling SP or through the SQL JOb.

Thanks

Prashant Pandey

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,062 questions
SQL Server Analysis Services
SQL Server Analysis Services
A Microsoft online analytical data engine used in decision support and business analytics, providing the analytical data for business reports and client applications such as Power BI, Excel, Reporting Services reports, and other data visualization tools.
1,292 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
102 questions
0 comments No comments
{count} votes

Accepted answer
  1. MikeyQiaoMSFT-0444 3,190 Reputation points
    2024-09-25T02:51:51.62+00:00

    Hi,PANDEY Prashant

    The SQL engine is unable to directly identify TMSL. Consider setting up an SQL job, and within SSMS (SQL Server Management Studio), configure a Linked Server for the SSAS (SQL Server Analysis Services) instance.

    Amend the stored procedure to convey the TMSL command to the Linked Server using JSON.

    CREATE PROCEDURE ProcessMonthlyPartition
    AS
    BEGIN
        DECLARE @CurrentMonth NVARCHAR(20)
        DECLARE @PartitionName NVARCHAR(100)
        DECLARE @JsonCommand NVARCHAR(MAX)
        DECLARE @CurrentYear NVARCHAR(4)
        DECLARE @DataBaseName NVARCHAR(100) = 'dev-ssas' 
        DECLARE @TableName NVARCHAR(100) = 'fact_viewing_session_member' 
        SET @CurrentMonth = DATENAME(MONTH, GETDATE())
        SET @CurrentYear = DATEPART(YEAR, GETDATE())
        SET @PartitionName = 'Partition_' + @CurrentMonth + '_' + @CurrentYear
       
        SET @JsonCommand = '{
            "refresh": {
                "type": "automatic",
                "objects": [
                    {
                        "database": "' + @DataBaseName + '",
                        "table": "' + @TableName + '",
                        "partition": "' + @PartitionName + '"
                    }
                ]
            }
        }'
        EXEC (@JsonCommand) AT SSASTABULAR;  -- linked server name
    END
    
    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.