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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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!😊

Anonymous
Not applicable

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

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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