Fetch SQL Server stored procedure output results into table -


i have tried solutions internet not working me .

my task out put of stored procedure table.the data being inserted inside cursor loop . creating temporary table store , display data.

my code:

alter procedure [dbo].[usp_test]    set nocount on;     declare @caseid int;    declare  @chg_id int;    declare @hear_id int;     set @chg_id = 1    set @testid = 1;     declare db_cursor cursor       select c_case_id      table1     // there multiple caseids         -- here trying delete temporary table, not work    if object_id('tempdb..##test_temp_table') not null        truncate table ##test_temp_table    else       create table test_temp_table(hear_id int)     open db_cursor      fetch next db_cursor @caseid      while @@fetch_status = 0       begin           insert test_temp_table          exec storedproctest2 @caseid, 1, @hear_id output;        -- loop through cursor     case ids       fetch next db_cursor @caseid         select hear_id test_temp_table;    end        close db_cursor      deallocate db_cursor; 

i have 2 issues:

  1. i cannot delete temporary table
  2. i not seeing output temporary table

[##test_temp_table] , [test_temp_table] 2 different tables. first 1 global temp table, second 1 user table. believe want replace user table global temp table, i.e. replace object [test_temp_table] [##test_temp_table]. or vice versa. in end, have ensure querying correct table.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -