0

I have a multilist field returning a list of values.

My query is filtering the list using IN (list), but if the user do not select anything is list, it returns an empty list, or null (I can't see).

I'm trying to do something like:

    case when @list is null then 1
             when c.SK_dimLocalizacao in (@list) then 1
             else 0
        end = 1

It works when I select none or one value, but if I select more than one it bring me an error.

I already tried to use:

    case when @list = '' then 1
             when c.SK_dimLocalizacao in (@list}) then 1
             else 0
        end = 1

I can't modify the query in backend because i'm using Pentaho.

3
  • 1
    one suggestion, you can use Tools > sql server profiler to see what is executing as @list in sql server management studio. Commented Aug 19, 2019 at 18:57
  • 1
    What is the error? Commented Aug 19, 2019 at 18:59
  • 1
    Please show @list declaration. If it's a string type, it will not work this way. You'll need to pass a user-defined table type and join Commented Aug 19, 2019 at 19:17

1 Answer 1

2

Maybe this? (not sure if I understand the end goal)

IF LEN(ISNULL(@list,'')) <> 0
BEGIN
   --Query for if the list isn't empty or null
END
ELSE
   --Query for if the list is empty or null
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.