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 8003191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:35:38+00:00 2026-06-04T16:35:38+00:00

I’m working in a client’s SQL Server 2005 database and I’m seeing some odd

  • 0

I’m working in a client’s SQL Server 2005 database and I’m seeing some odd behavior. I have a little experience with 2008, but this is my first battle with 2005, so I’m hoping this turns out to be something simple related to my inexperience.

What am I trying to do? I am developing a sales dashboard in SSRS 2005. One of the report parameters is a multi-value parameter which I need to pass to a stored procedure. I found a work around in some blogs, as well as here on SO, and implemented a function which splits a comma delimited varchar, and returns a table. I need this function to return the correct values from within the procedure, since I am calling stored procedures for the SSRS datasets.

My Problem: When I execute the function directly from within SSMS for a given value, I receive a table with 7 rows (as expected). When I execute a procedure that calls that function, with the same values passed, it only returns 1 row in the table. The user executing the function and the procedure is also the owner of both objects.

I’ve done a lot of homework to get to this point prior to posting the question, so I hope I’ve done my due diligence here. The client hasn’t given me privileges to work with SQL Profiler, so I haven’t been able to dig in that direction.

I thought perhaps this could be a permissions issue, but the fact that the function is still executed and does return 1 row instead of 7 confused me. It appears to only return the first number from the comma dilimitted string.

My Question: What the heck is causing the behavior outlined below? Please let me know if I should provide any additional information.

Executed from SSMS:

declare 

    @SiteID varchar(max);

    set @SiteID = '1,2,3,4,5,6,7';

BEGIN

exec usp_function_test @SiteID;

select * from udf_rpt_multivalueparamtotable(@SiteID,',',1)

END

Output from Procedure:

Val
---
1

Output from select statement:

Val
---
1
2
3
4
5
6
7

Function Code:

CREATE FUNCTION [dbo].[udf_RPT_MultiValueParamToTAble](
            @String VARCHAR(max), /* input string */
   @Delimeter char(1),   /* delimiter */
   @TrimSpace bit )      /* kill whitespace? */
RETURNS @Table TABLE ( [Val] VARCHAR(4000) )
AS

BEGIN
    DECLARE @Val    VARCHAR(4000)
    WHILE LEN(@String) > 0
    BEGIN
        SET @Val    = LEFT(@String,
             ISNULL(NULLIF(CHARINDEX(@Delimeter, @String) - 1, -1),
             LEN(@String)))
        SET @String = SUBSTRING(@String,
             ISNULL(NULLIF(CHARINDEX(@Delimeter, @String), 0),
             LEN(@String)) + 1, LEN(@String))
  IF @TrimSpace = 1 Set @Val = LTRIM(RTRIM(@Val))
    INSERT INTO @Table ( [Val] )
        VALUES ( @Val )
    END
    RETURN
END

Test Procedure Code:

CREATE PROCEDURE usp_function_test (@SiteID varchar)
AS

SET NOCOUNT ON

BEGIN

select * from udf_rpt_multivalueparamtotable(@SiteID,',',1)

END
  • 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-04T16:35:39+00:00Added an answer on June 4, 2026 at 4:35 pm

    Try defining a scale for the SP parameter –

    CREATE PROCEDURE usp_function_test (@SiteID varchar(max))
    

    When you declare a varchar parameter without a scale, it defaults to a scale of 1 – your input value was being silently truncated.

    Reference here – http://msdn.microsoft.com/en-us/library/ms176089.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a reasonable size flat file database of text documents mostly saved in
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

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.