Hoping I'm just over looking something. I have the query below in SSMS and it works just fine. (There are additional Insert and Update sections that were removed in this example for clarity.) When I try to add a Dataset in SQL Server BIDS, the @season parameter isn't available. When I alter the query and remove the insert statement, the parameter becomes available. I don't do a lot with SSRS reports normally but trying to move that way.
Thanks in advance
USE [impresario]GO/****** Object: StoredProcedure [dbo].[LP_PAF_PERF_PROOF_1] Script Date: 06/05/2018 15:31:02 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[LP_PAF_PERF_PROOF_1] @season int = nullASBEGIN SET NOCOUNT ON; create table #results(perf_no int,perf_name varchar(100),perf_code varchar(20),perf_dt datetime)
insert #results (perf_no, perf_name, perf_code, perf_dt) select p.perf_no as i_perf_no, i2.description as i_perf_name, p.perf_code as i_perf_code, p.perf_dt as i_perf_dt--, from T_PERF pjoin TR_SEASON s on p.season = s.idjoin T_INVENTORY i on p.prod_season_no = i.inv_nojoin T_INVENTORY i2 on p.perf_no = i2.inv_nojoin TR_PERF_STATUS ps on p.perf_status = ps.idwhere p.season = @seasonorder by p.perf_dt
select *from #resultsorder by perf_no
return
END
Although not sure why any of these would affect how BIDS sees parameters depending on the insert statement being present or not.
I am assuming this is a snippet as otherwise the insert into the table is superfluous as you could just run the insert select statement directly
The following changes are personal preference
Here is what your code snippet would look like if I had written it
USE [impresario]GO/****** Object: StoredProcedure [dbo].[LP_PAF_PERF_PROOF_1] Script Date: 06/05/2018 15:31:02 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[LP_PAF_PERF_PROOF_1] (--CREATE PROCEDURE #LP_PAF_PERF_PROOF_1 ( -- create statement for a temporary stored procedure which is useful for testing when sp is running Live @season int = null)ASSET NOCOUNT ON/***********************************************************************************************************************************
Always have a block of comments at the start so I can write relevant details about the spAlways include the execute statement to run, as makes it easier for someone else to know what should return resultsexecute LP_PAF_PERF_PROOF_1 @season=100Also execute for the temp procedure if you use thatexecute #LP_PAF_PERF_PROOF_1 @season=100
***********************************************************************************************************************************/
BEGIN
declare @results as table ( perf_no int primary key, perf_name varchar(100), perf_code varchar(20), perf_dt datetime )
insert @results (perf_no, perf_name, perf_code, perf_dt) select i_perf_no = p.perf_no, i_perf_name = i2.description, i_perf_code = p.perf_code, i_perf_dt = p.perf_dt from T_PERF p join TR_SEASON s on p.season = s.id join T_INVENTORY i on p.prod_season_no = i.inv_no join T_INVENTORY i2 on p.perf_no = i2.inv_no join TR_PERF_STATUS ps on p.perf_status = ps.id where p.season = @season order by p.perf_dt
select * from @results order by perf_no
Hope that helps
Mark