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
redexecutive
New Member

Stored Procedure parameters with dates

Really I don´t know how to manage this, I am trying to use a simple stored procedure (for now) with 2-date parameters.

 

CREATE PROC usp_Sel_Reporte_Indicadores @dtFechaIni DATE = NULL, @dtFechaFin DATE = NULL

AS

 

 

IF @dtFechaIni = NULL

SET @dtFechaIni = GETDATE()

IF @dtFechaFin = NULL

SET @dtFechaIni = GETDATE()

 

 

---Tiempo Disponible

SELECT *

FROM dbo.DC_VW_Paros

WHERE Fecha BETWEEN @dtFechaIni AND @dtFechaFin

 

 

this is my connection instruction:

 

let
    Source = Sql.Database(Sqlnstance, Database, [Query="EXEC usp_Sel_Reporte_Indicadores '" & Date.ToText(FechaIni,"yyyyMMdd") & "','" & Date.ToText( FechaFin,"yyyyMMdd")  & "'"])
in
    Source

 

With these 2 parameters

Capture.PNG

 

And in the Query Editor works correctly ,but when I close & apply changes show me this error

Capture2.PNG

 

I appreciate any idea

1 ACCEPTED SOLUTION

Hi redexecutive,

 

I have confirmed this issue from PG.  Actually, this is another limitation of DirectQuery that does not permit to use a store procedure.

Only queries with the form Select … From … Where … are allowed.

 

Best Regards,

Jimmmy

View solution in original post

6 REPLIES 6
v-yuta-msft
Community Support
Community Support

Hi redexecutive,

 

I have reproduced your issue, I made a simple table and created a procedure usp_Sel_Reporte_Indicadores with your script in SQL Server.

3.PNG

Fisrtly I tested import mode, I created 4 parameters like yours and created a new query with your script.

1.PNG2.PNG

It worked well in Query Editor and after I clicked “close&apply” button there was no error.

4.PNG

However, when I test in direct query mode, I encountered the same error with you after clicking “apply” button like below:

 Capture2.PNG

After that I modified my SP with no input params, the error still existed. It seems that there are some limitations with SQL query in  direct query mode(e.g.:maybe don’t support execute SP)

 

I have sent a mail to PG to confirm this issue. Currently, as a workaround, you can use import mode instead of direct query mode.

 

Regards,

Jimmy Tao

Thanks v-yuta-msft for your quick answer, but my client need the information online, and there are a lot of calculations there. 😞

Regards

Hi redexecutive,

 

I have confirmed this issue from PG.  Actually, this is another limitation of DirectQuery that does not permit to use a store procedure.

Only queries with the form Select … From … Where … are allowed.

 

Best Regards,

Jimmmy

Thanks for the clarification 😀 I will not waste my time anymore in this solution type.
Anonymous
Not applicable

What happens if you change the date format from "yyyyMMdd" to "yyyy-MM-dd" ?

Hi:

Thanks for answer but throws this error

"Expression.Error: This native database query isn't currently supported."

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.