Object Variable type and Expressions

Asked

Viewed 106 times

3

I wonder if you have any way to mount an Xpression on ssis that returns true or false on a variable of type Object :

basically would be something like in sql 12 in (14,25,45,12,54) but in Expression instead of a list would be something like

numero in objectVariable 
  • Could you create a more elaborate example than you want? I don’t understand.

  • I have an object-type variable that takes values from the result of a query, so it has several lines as a result. i would like to do an Expression to know if a number n belongs to the collection of numbers returned within the variable if it has this number it will perform the action A if not the action B @gmsantos

  • I think your need can be simplified with some derived column combined with a lookup or conditional split than an obscure Expression like that.

2 answers

2

If it is in SQL Server 2012, you can mount a micro-table that works as an array:

DECLARE @ListaDeIDs TABLE(IDs int);
INSERT INTO @ListaDeIDs
VALUES(14),(25),(45),(12),(54);
SELECT IDs FROM @ListaDeIDs;
GO

Then the comparison goes like this:

SELECT ...
WHERE 12 IN (SELECT IDs FROM @ListaDeIDs)
  • believe that was not my doubt, my doubt would be like mounting an expression in sql servert Integration services where it checks if there is a number such within a variable of type Object that received the values of a result being of multiple lines.

  • 1

    And Integration Services doesn’t accept T-SQL? Weird.

2


If you are able to generate the sequence of comma values at the beginning of the end, you can use the function CHARINDEX to locate the number.

Example:

SELECT *
FROM table
WHERE CHARINDEX( 
        ',54,' , 
        ',14,25,45,12,54,'
    )

Or:

SELECT *
FROM table
WHERE CHARINDEX(
        ',' + CAST(numero as VARCHAR) + ',' , 
        ',14,25,45,12,54,'
    )

Browser other questions tagged

You are not signed in. Login or sign up in order to post.