I am trying to run a SQL Server stored procedure in Power BI that has parameters and I am getting this error:
DataSource.Error: Microsoft SQL: Named Pipes Provider: Could not open a connection to SQL Server [2].
Details:
DataSourceKind=SQL
DataSourcePath=xxx-xxxxxx\xxxxx;xxxx
Message=Named Pipes Provider: Could not open a connection to SQL Server [2].
ErrorCode=-2146232060
Number=2
Class=16
State=1
Source = Sql.Database("xxx-xxxxxx\xxxxx", "xxxx", [Query="SELECT * FROM #(lf)OPENROWSET('SQLNCLI','trusted_connection=yes', 'exec xxxx..sp_storedprocedure @StartDate=" & StartDate & ", @EndDate=" & EndDate & "')", CreateNavigationProperties=false])`
Above is what the advanced editor has. I know it is not the named pipes in the SQL Server config manager because it is enabled and other queries work fine in PowerBI. I have also restarted the SQL Server services a number of times but no luck as well.
Any help would be greatly appreciated. Thanks.
CREATE PROCEDURE [dbo].[sp_Demo_kpi] @StartDate datetime, @EndDate datetime
AS
--Set @StartDate = DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE())-1, 0);
--Set @EndDate = DATEADD(MONTH, DATEDIFF(MONTH, -1, GETDATE())-1, -1);
--SELECT
SELECT [Snapshot_ID]
,[Cost to Complete]
,[Cost to Complete (SS)]
,[CtC PM Notes]
,[CtC Variance]
,[PCOs]
,[PM Manual CtC Override]
,[Previous Month (CtC)]
,[Project]
,[Project Number]
,[Projected Contract]
,[Projected Over/Under]
,[Remaining Exposure]
,[Revised Contract]
,[Total Cost Incurred]
,[UnitCode]
,[Approved COs]
,[Cost Code]
,[CPCOs]
,[Current Commitment]
,[Invoices]
,[Original Budget]
,[Original Commitment]
,[ImportDate]
,[CtC Modifications Notes (Previous Month)]
,@StartDate AS StartDate
,@EndDate AS EndDate
FROM [Buckingham].[dbo].[tbl_UnitTracker_NonReno_Snapshot]
WHERE ImportDate BETWEEN CONVERT(DATETIME, @StartDate, 101)
AND CONVERT(DATETIME, @EndDate, 101);