# Radzen unable to read the results from stored procedure

**URL:** <https://forum.radzen.com/t/radzen-unable-to-read-the-results-from-stored-procedure/14621>\
**Category:** Angular\
**Created:** [July 3, 2023, 4:23am UTC](https://forum.radzen.com/t/radzen-unable-to-read-the-results-from-stored-procedure/14621 "2023-07-03T04:23:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AbhishekJ](https://forum.radzen.com/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@AbhishekJ](https://forum.radzen.com/u/AbhishekJ)\
**Post date:** [July 3, 2023, 4:23am UTC](https://forum.radzen.com/t/radzen-unable-to-read-the-results-from-stored-procedure/14621/1 "2023-07-03T04:23:50Z")

</div>

We have a stored procedure mentioned below in SQL Server. Which returns two different tables depending on @pagename parameter. Radzen is able to read the table only for stored procedure 1. However, when we introduce a set of IF statements to return different tables depending on the selected @pagename parameter. Radzen is unable to read the table returned by the stored procedure. We have two separate pages for the two tables and depending on @pagename parameter we want the individual pages to display the correct table. The stored procedures work correctly when executed on SQL server

**STORED PROCEDURE 1:**

ALTER PROCEDURE [dbo].[usp\_Master\_GetData\_DataGrids\_JCM]  
-- Add the parameters for the stored procedure here

```
@pagename varchar(100),
@runid int

```

AS  
BEGIN  
-- SET NOCOUNT ON added to prevent extra result sets from  
-- interfering with SELECT statements.  
SET NOCOUNT ON;

```
-- Insert statements for procedure here
Declare @uspname varchar(MAX) = NULL, @ResultfromSP varchar(4192)=NULL

```

BEGIN TRY

```
SELECT * from ufn_Get_SurfaceTreatmentData_JCM(@runid)

```

END TRY

BEGIN CATCH  
SELECT @ResultfromSP = 'Error Line , '+ Convert(char,ERROR\_LINE()) + ', Error Message , '+ ERROR\_MESSAGE() + ', Error Number , '+ CONVERT(char,ERROR\_NUMBER())  
END CATCH

END

**STORED PROCEDURE 2:**

ALTER PROCEDURE [dbo].[usp\_Master\_GetData\_DataGrids\_JCM]  
-- Add the parameters for the stored procedure here

```
@pagename varchar(100),
@runid int

```

AS  
BEGIN  
-- SET NOCOUNT ON added to prevent extra result sets from  
-- interfering with SELECT statements.  
SET NOCOUNT ON;

```
-- Insert statements for procedure here
Declare @uspname varchar(MAX) = NULL, @ResultfromSP varchar(4192)=NULL

```

BEGIN TRY

```
IF @pagename = 'surfacetreatment'
BEGIN
		SELECT * from ufn_Get_SurfaceTreatmentData_JCM(@runid)

END

IF @pagename = 'isrepair'
BEGIN
		SELECT * from ufn_Get_ISrepairData_JCM(@runid)

END

```

END TRY

BEGIN CATCH  
SELECT @ResultfromSP = 'Error Line , '+ Convert(char,ERROR\_LINE()) + ', Error Message , '+ ERROR\_MESSAGE() + ', Error Number , '+ CONVERT(char,ERROR\_NUMBER())  
END CATCH

END

Regards,  
Abhishek

---

<div class="post-metadata">

**Author:** ![enchev](https://forum.radzen.com/user_avatar/forum.radzen.com/enchev/32/16_2.png) [@enchev](https://forum.radzen.com/u/enchev)\
**Post date:** [July 3, 2023, 4:34am UTC](https://forum.radzen.com/t/radzen-unable-to-read-the-results-from-stored-procedure/14621/2 "2023-07-03T04:34:25Z")

</div>

To retrieve stored procedures and their parameters we are using [sys.dm\_exec\_describe\_first\_result\_set\_for\_object](https://learn.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-exec-describe-first-result-set-for-object-transact-sql?view=sql-server-ver16). It however does not work for all stored procedures especially for such than will return different results based on some conditions.
