Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7892255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:49:28+00:00 2026-06-03T06:49:28+00:00

I have created a stored procedure (to be used in SSRS) that has parameters

  • 0

I have created a stored procedure (to be used in SSRS) that has parameters whose values are more than one. When I execute this stored procedure in SSMS by providing the values for that parameter, SP doesn’t return any result. It should return more than 1 rows

Below is the SP given

CREATE PROCEDURE [dbo].[sp_tst_CSENG_JulieCapitalHours]
        @StartDate DATETIME ,
        @EndDate DATETIME ,
        @ProjHomeGrp NVARCHAR(MAX) ,
        @ProjHier NVARCHAR(MAX)
AS  
BEGIN
    SELECT  [Capital Project] ,
                    [Capital Task] ,
                    ResourceName ,
                    ProjectName ,
                    [Project Home Group] ,
                    ActualWork ,
                    TimeByDay ,
                    ResourceStandardRate ,
                    ActualWork * ResourceStandardRate AS Dollars ,
                    [Project Hierarchy]
    FROM [IR.CapOnly]
    WHERE ( TimeByDay >= @StartDate )
      AND ( [Project Home Group] IN ( @ProjHomeGrp ) )
      AND ( TimeByDay <= @EndDate )
      AND ( ActualWork > 0 )
      AND ( [Project Hierarchy] IN ( @ProjHier ) )
    ORDER BY ProjectName ,
             ResourceName
END 

You can see that in the where clause, Project Home Group (@ProjHomeGrp) and Project Hierarchy (@ProjHier) are the parameters, whose value when supplied (more than 1) SP returns zero values.

The value that I’m passing are:

Start Date: 1/1/2011 
End Date: 12/31/2012
@ProjHomeGrp : PHG1,PHG2,PHG3,PHG4,PHG5,PHG6,PHG7
@ProjHier: PROH1, PROH2, PROH3

Let me know for any questions!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:49:29+00:00Added an answer on June 3, 2026 at 6:49 am

    As Oded said, table valued parameters are the way to go. However, here is a solution based on dynamic sql, with all the problems that might imply…

    create procedure [dbo].[sp_tst_CSENG_JulieCapitalHours]
            @StartDate datetime ,
            @enddate datetime ,
            @ProjHomeGrp nvarchar(MAX) ,
            @ProjHier nvarchar(MAX)
        as  
    begin
        declare @sql nvarchar(max)
        declare @paramDefs nvarchar(max)
    
        select @sql = N'select  [Capital Project] ,
                [Capital Task] ,
                ResourceName ,
                ProjectName ,
                [Project Home Group] ,
                ActualWork ,
                TimeByDay ,
                ResourceStandardRate ,
                ActualWork * ResourceStandardRate AS Dollars ,
                [Project Hierarchy]
        from    [IR.CapOnly]
        where   ( TimeByDay >= @StartDate )
                and ( [Project Home Group] IN (' + @ProjHomeGrp + ') )
                and ( TimeByDay <= @EndDate) )
                and ( ActualWork > 0 )
                and ( [Project Hierarchy] IN ( ' + @ProjHier + ' ) )
        order by ProjectName, ResourceName'
    
        select @paramDefs = N'@StartDate datetime, @EndDate datetime'
    
        exec sp_executesql @sql, @paramDefs, @StartDate = @StartDate, @EndDate =  @EndDate
    end 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a stored procedure GetNotifications that returns all notifications for a specific
I have created a stored procedure for selecting value from the table if that
I have a Firebird stored procedure that accepts Decimal(9,6) values for Latitude and Longitude
I have a stored procedure that consists of a single select query used to
I have just created a report in Report Manager using a Stored Procedure which
I have a dynamic SQL statement I've created in a stored procedure. I need
I have a stored procedure that is working with a large amount of data.
I have a MySQL stored procedure that uses a temporary table. Assume that my
I want to make a Stored Procedure that has a minimum of 2 required
I have just written a stored procedure and stored function that serve to insert

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.