Error while Running Predict Function in Synapse Studio

Sneha Sheshadri 1 Reputation point
2020-07-10T01:02:58.17+00:00

Getting an error Incorrect Syntax near 'Model' while running the Prediction function in T-SQL statement. The below query was tried on Azure Synapse Studio as well SSMS and did not work

DECLARE @modelvarbinary(max) = (SELECT Model FROM [wwi_mcw].[ASAMCWMLModel] WHERE Id = (SELECT Top(1) max(ID)
FROM [wwi_mcw].[ASAMCWMLModel]));

Select d.,p. from PREDICT(MODEL=@model,DATA=[wwi_mcw].[ProductPCA]as d) WITH(prediction real)as p;

GitHub link Referenced for the above example: https://github.com/microsoft/MCW-Azure-Synapse-Analytics-end-to-end-solution

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,504 questions
{count} votes

1 answer

Sort by: Most helpful
  1. HimanshuSinha-msft 19,381 Reputation points Microsoft Employee
    2020-07-13T21:09:17.137+00:00

    Hello @SnehaSheshadri-7717,

    Thanks for the question and also for using this forum.

    On a very quick glance I can see the issue with the line

    DECLARE @modelvarbinary(max) = (SELECT Model FROM [wwi_mcw].[ASAMCWMLModel] WHERE Id = (SELECT Top(1) max(ID)
    FROM [wwi_mcw].[ASAMCWMLModel]));

    It should be ( please beware that there is a space between @model & varbinary )

    DECLARE @model varbinary(max) = (SELECT Model FROM [wwi_mcw].[ASAMCWMLModel] WHERE Id = (SELECT Top(1) max(ID)
    FROM [wwi_mcw].[ASAMCWMLModel]));

    Please do let em know how it goes .

    Thanks & stay safe
    Himanshu
    Please do consider to click on "Accept Answer" and "Up-vote" on the post that helps you, as it can be beneficial to other community members

    0 comments No comments