Forum Discussion

shavish's avatar
shavish
Helper I
1 year ago
Solved

SQL syntax error

Hello all,   Am trying to add data from SQL server through direct query option. When i add data and i am getting following error: Microsoft SQL: Incorrect syntax near the keyword 'DECLARE'. Incorr...
  • hnguy71's avatar
    1 year ago

    Hi shavish 

    Power BI wraps your query statement in another SELECT statement, therefore, you won't be able to use the DECLARE function.

     

    You can try this instead:

    SELECT
    CONVERT(varchar(50), Table1.names) As Name,
    CONVERT(varchar(50), Table1.id) As ID,
    
    FROM
    Table1