sql server - Passing values from first stored procedure to another is not working -


please help. have created stored procedure in no values have passed. like: create procedure updatetablemonthlytrend

inside have declared variables , have stored values them table. like:

@previousmonth , @currentyear 

now these values passing storedprocedure have created earlier accepting these variables' values.

create procedure tablemonthlytrend (@previousmonth varchar(20), @currentyear int) 

from first procedure passing values second procedure like:

exec tablemonthlytrend @previousmonth, @currentyear. 

but while executing first procedure nothing passing down second procedure. when exec updatetablemonthlytrend --nothing happens , second procedure runs not functioning should do.

please , let me know mistake doing.

here first sp:-

alter procedure [dbo].[bo_sp_update_supportkpi_monthlytrend]  begin  begin transaction; begin try   create table #temp_currentdatetime (id int identity(1,1), currentdate datetime, currentmonth varchar(15), previousmonth varchar (15), currentyear varchar(10) )  insert #temp_currentdatetime values     (getdate(),month(getdate()),month(dateadd(mm,datediff(mm,0,getdate())-1,0)),year    (getdate()))  update #temp_currentdatetime set  previousmonth =  case                       when previousmonth = 1 'january'                      when previousmonth = 2 'february'                      when previousmonth = 3 'march'                      when previousmonth = 4 'april'                      when previousmonth = 5 'may'                      when previousmonth = 6 'june'                     when previousmonth = 7 'july'                      when previousmonth = 8 'august'                      when previousmonth = 9 'september'                     when previousmonth = 10 'october'                      when previousmonth = 11 'november'                      when previousmonth = 12 'december'                     else previousmonth                 end    id = 1   declare @previousmonth varchar(50) set @previousmonth = (select previousmonth #temp_currentdatetime    id = 1)  declare @currentyear int set @currentyear = (select currentyear #temp_currentdatetime )  declare @yearfromtable int set @yearfromtable = (select top 1 year bo_supportkpi_monthlytrend_new    order year desc)  if @previousmonth = 'december' begin  set @currentyear = @yearfromtable    if @previousmonth = (select column_name information_schema.columns         table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 9) begin exec bo_sp_supportkpi_monthlytrend   @previousmonth,@currentyear end  else if @previousmonth = (select column_name             information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new'                   , ordinal_position = 10) begin exec bo_sp_supportkpi_monthlytrend    @previousmonth,@currentyear end  else if @previousmonth = (select column_name       information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new'        , ordinal_position = 11) begin exec bo_sp_supportkpi_monthlytrend @previousmonth,@currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 12) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 13) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 14) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 15) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 16) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 17) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 18) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 19) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 20) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end end  else begin  set @previousmonth = @previousmonth set @currentyear = @currentyear        if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 9) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 10) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 11) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 12) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 13) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 14) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 15) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 16) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 17) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 18) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 19) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end  else if @previousmonth = (select column_name information_schema.columns table_name = 'bo_supportkpi_monthlytrend_new' , ordinal_position = 20) begin exec bo_sp_supportkpi_monthlytrend @previousmonth, @currentyear end end  end  end try begin catch      if @@trancount > 0         rollback transaction; end catch;  if @@trancount > 0     commit transaction; end  go 


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -