1

I have a stored procedure I do not have access to edit called [usp_ItemsAndDescriptions].

This gives a result, and my call looks like this:

USE [eboghandel]
GO

DECLARE @return_value int

EXEC    @return_value = [dbo].[usp_ItemsAndDescriptions]
        @StartDate = N'2014-06-01',
        @EndDate = N'2014-06-19',
        @Top = 10000

SELECT  'Return Value' = @return_value

GO

This stored procedure then gives a list of fields. One of the fields are called PressDescription.

Now I want to make a WHERE statement, so I could say:

SELECT * FROM MYSTOREDPROCEDURERESULT mys WHERE mys.PressDescription = '1'

What is the syntax to do this? I do not have access to edit the stored procedure unfortunately, even though that would be optimal.

Lars Holdgaard
  • 9,496
  • 26
  • 102
  • 182

1 Answers1

1

You should load return data from SP to temporary table and filter this table by WHERE clause:

Create temporary table:

CREATE TABLE #tmp
(
   ...
)

Insert data in table

INSERT INTO #tmp
EXEC usp_ItemsAndDescriptions 
@StartDate = N'2014-06-01',
@EndDate = N'2014-06-19',
@Top = 10000

Filter your data

SELECT * FROM #tmp mys WHERE mys.PressDescription = '1'

Also check this link - there a lot of methods to load data from SP Insert results of a stored procedure into a temporary table

Community
  • 1
  • 1
MikkaRin
  • 3,026
  • 19
  • 34