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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:09:50+00:00 2026-05-23T15:09:50+00:00

SQL Server 2005. I have a stored procedure which accepts a few parameters that

  • 0

SQL Server 2005.

I have a stored procedure which accepts a few parameters that may or may not actually have data passed to them. So they may come through as an empty string, or they may come through with data.

The data would be a delimited list of IDs… manufacturer ID, catalog ID, etc. The proc searches through records, and if any of those parameters have data, it’s used in the where clause.

FYI: Split is a function that splits a string (accepts a delimiter) and returns a table.


WHERE

...

AND m.Mfg_ID in (CASE WHEN @manufacturerIds <> '' THEN (SELECT * FROM Split(@manufacturerIds, '|')) ELSE (select m.Mfg_Id) END)

I get an error of:
“Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.”

What I don’t understand is that if I remove the CASE statement, so that I just have this…


WHERE

...

AND m.Mfg_ID in (SELECT * FROM Split(@manufacturerIds, '|'))

… it runs OK; however, this keeps me from being able to pass an empty string.

Any help would be much appreciated!

  • 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-05-23T15:09:51+00:00Added an answer on May 23, 2026 at 3:09 pm

    The difference is that (select m.Mfg_Id) returns a single row, but (select * from split(...)) returns multiple rows. A case returns a single value, so it doesn’t know what to do with the multiple rows from Split.

    Instead of a case you could union them together:

    and m.Mfg_ID in 
    (
    select  *
    from    Split(@manufacturerIds, '|')
    where   @manufacturerIds <> ''
    union all
    select  m.Mfg_Id
    where   @manufacturerIds = ''
    )
    

    The bottom half of the union only runs when @manufacturerIds = ''.

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

Sidebar

Related Questions

I have a stored procedure in SQL Server 2005 which accepts few parameters of
All, I have a stored procedure on SQL Server 2005 that accepts an XML
I have a very long-running stored procedure in SQL Server 2005 that I'm trying
I have a stored procedure on a SQL Server 2005 database which has a
Working in SQL Server 2005, I have a stored procedure that inserts a record
We have a page calling a Search stored procedure which internally uses SQL Server
I have designed a stored procedure usign Sql Server 2005 below to compare 3
I have created a stored procedure in SQL Server 2005, also I create another
I am using MS SQL Server 2005, I have dates stored in epoch time
In SQL Server 2005 I have an id field in a table that has

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.