Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Get DATA using temporary table from SQL

Hi, I am trying to execute a sql query and receiving the syntax:  (SQL is created a temporary table.)

 

"microsoft sql incorrect syntax near the keyword 'into'. incorrect syntax near ')'. power bi

 

Any help would be appreciated.

tks/

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Figured it out.  Thank you both for your help.

I was trying to do a 'Direct Query' vs 'Import Query'.

Hope you are safe and well... thanks again!😊

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

I am unsure if my remark will be read but I wanted to discover the most efficient way to pull data that uses a SQL Server QUERY  to pull  data from a Temporary table in Power Bi and use incremental refresh too as the report will be updated daily.  I suppsoe going the stored procedure route is the best?  Any advice is certainly welcome as this is a very large and unruly dataset!

Fowmy
Super User
Super User

@Anonymous 

Seems like you have a syntax error in your SQL code, please re-check.

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

I agree, but the code works in SSMS, but won't pull in PBI.  

 

part of code:

SELECT DISTINCT ll.LoadId

 

INTO #LoadFilter

 

[code]

 

DROP TABLE #LoadFilter

 

PBI  does not like the 'INTO' .  Not a SQL expert nor PBI expert, but know a little to understand the error.

@Anonymous 

 

It seems that PowerBI cannot translate the SQL Query properly.

 

Instead of temp table why dont you use a CTE (in memory table) in your sql query??

 

Another option is to create a store procedure, add the sql query code there and then call the procedure from PowerBI. Like:

 

DECLARE @sqlcode varchar(1000)

SET @sqlcode= 'dbo.queryproc
EXEC (@sqlcode)

Anonymous
Not applicable

Figured it out.  Thank you both for your help.

I was trying to do a 'Direct Query' vs 'Import Query'.

Hope you are safe and well... thanks again!😊

Hi @Anonymous ,

Is there anything else need help about this thread? If no, could you please mark your post as Answered? It will help the others in the community find this solution easily if they face the same problem with you. Thank you.

Otherwise, you can refer the following links to get it.

Connect using advanced options

Working with SQL Server data in Power BI Desktop

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.