Forum Discussion
shavish
1 year agoHelper I
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
1 year agoSuper User
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
ajohnso2
1 year agoSolution Supplier
hnguy is correct but just included an extra comma.
SELECT
CONVERT(varchar(50), Table1.names) As Name,
CONVERT(varchar(50), Table1.id) As ID
FROM
Table1
You cannot use the key word declare in the sql query window from power bi