Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

SSRS calling stored procedure displays only one record

$
0
0

Hi,

I have a store procedure below.  I ran it and it seems to be working fine.  Basically giving a first name filter, it displays the first name and lastname from the table.   Though calling it from SSRS, somehow after entering the filter and run the report, it only shows the first record retrieved from the table instead of the whole thing.  Can you tell me what is happening? I am new to stored procedure, and have not tried calling a stored procedure from SSRS

ALTER PROCEDURE [dbo].[sp_t_contact]
(    @filter varchar (10)
)

AS
BEGIN
    SET NOCOUNT ON
  
-- Declare the variables to store the values returned by FETCH.
DECLARE @contact_first_name varchar(50), @contact_last_name varchar(50);

DECLARE contact_cursor CURSOR FOR
SELECT contact_first_name, contact_last_name FROM t_contact
WHERE --contact_first_name LIKE 'J%' and 
contact_first_name like @Filter+'%'
ORDER BY contact_first_name, contact_last_name;

OPEN contact_cursor;

-- Perform the first fetch and store the values in variables.
-- Note: The variables are in the same order as the columns
-- in the SELECT statement. 

FETCH NEXT FROM contact_cursor
INTO @contact_first_name, @contact_last_name;

-- Check @@FETCH_STATUS to see if there are any more rows to fetch.
WHILE @@FETCH_STATUS = 0
BEGIN

   -- Concatenate and display the current values in the variables.
 --  PRINT 'Contact Name: ' + @contact_first_name + ' ' +  @contact_last_name
 select @contact_first_name FirstName , @contact_last_name LastName
   -- This is executed as long as the previous fetch succeeds.
   FETCH NEXT FROM contact_cursor
   INTO @contact_first_name, @contact_last_name;
END

CLOSE contact_cursor;
DEALLOCATE contact_cursor;
--go;




END






Thank You Warmest Fanny Pied


Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>