Forum Discussion
shavish
Helper I
1 year agoSQL 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
Super User
1 year agoHi 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
Solution Supplier
1 year agohnguy 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