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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. 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!😊

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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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