How can you use an execute statement before your SELECT statement in an SSRS dataset without getting the fields from the first stored procedure?

Sherri Norris 0 Reputation points
2023-07-17T20:32:10.0266667+00:00

I have a drop-down list that I want to populate in SSRS. The stored procedure that I am using to populate the drop-down list executes another stored procedure that refreshes a table and return values. When I use this new stored procedure to call the first one and return only one field, I get a row for every row in the first stored procedure. How can I only get the one field (which is a distinct select) in my drop-down list?

Example:

Stored Procedure 1


CREATE STORED PROC sp_UpdateTable
	EXEC sp_Table1
	SELECT A,B,C FROM Table1
END PROC

Stored Procedure 2
CREATE STORED PROC sp_UpdateTable
   	EXEC sp_Table1
 	SELECT DISTINCT B FROM Table1
END PROC

The desired result is that I want my drop-down to just show the unique refreshed values from column B, but I am getting A,B, and C returned in my dataset.

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-07-18T02:10:58.44+00:00

    Hi @Sherri Norris

    Are you trying to create a parameter dropdown? I don't know T-sql very well, but according to the information I searched, the statement to create a stored procedure is:

    CREATE PROCEDURE SelectAllCustomers
    AS
    SELECT * FROM Customers
    GO;
    
    

    My test:

    Screenshot 2023-07-18 095822

    Screenshot 2023-07-18 095901

    Screenshot 2023-07-18 095955

    Screenshot 2023-07-18 100030

    For more details, you can refer to this link: https://www.tutorialgateway.org/create-ssrs-report-using-stored-procedure/.

    If the answer is helpful, please click Accept Answer and Up-Vote for the same. If you have any questions, please feel free to let me know.

    Best regards,

    Aniya

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.