Forum Discussion
How to use a SQL Server Stored Proc (with no parameters) as a datasource ?
- 6 years ago
In SQL can you create a view that calls the stored proc then hit the view from Power BI?
Yes, you can use a stored procedure as "datasource" IF the stored procedure returns a table. I have created this simple test and it works:
CREATE TABLE TableTest
(
NAME VARCHAR(100),
AGE INT
)
INSERT INTO TableTest
VALUES
('Jonh Doe', 20),
('Tom Wayne', 35),
('Tony Clark', 40)
SELECT * FROM TableTest
CREATE PROCEDURE ProcedureTest
AS
BEGIN
SELECT * FROM TableTest
END
EXEC ProcedureTest
If I execute this SQL code on SQL Server Management Studio it will return 3 lines with 2 columns containing the content of TableTest.
If you go to Power BI and go to "Get Data", choose "SQL Server Database" and put the IP, click on bottom button to "Advanced Options" and put EXEC ProcedureTest in the field for "SQL Instruction" it will load and show the return of procedure, if the return is a table, you will see a table. Like the following:
- Anonymous6 years agoNot applicable
Same issue, I have the latest version of PBI Desktop "Version: 2.82.5858.961 64-bit (June 2020)"
- gluizqueiroz6 years ago
Resolver I
Could you try "Import" type and use "EXEC procedure" instead "EXECUTE procedure"?
(I use Power BI in Portuguese)Return:
- jdbuchanan716 years ago
Super User
gluizqueiroz is correct, it only works with import mode, not direct query.