简体   繁体   中英

How to use like condition in Conditional Split in SSIS

I am using conditional split to filter out the data from table. I have couple of conditions to check for. For example, In Email column, value should not contain ~ character and contain @ sign. Date of birth column, year should not be greater than current year, month should not be greater that 12 and day should not be greater than 31.

SELECT *
FROM [table]
WHERE Email LIKE '%~%'
   OR NOT (Email LIKE "%@%")
   OR SUBSTRING(CONVERT(varchar, DOb, 23), 1, 2) <= 12
   OR SUBSTRING(CONVERT(varchar, DOb, 23), 4, 2) <= 31
   OR SUBSTRING(CONVERT(varchar, DOb, 23), 7, 4) <= YEAR(GETDATE());

I have above sql query for the same. But not sure how to implement it in SSIS using conditional split.

Add additional columns in your source query depending on your conditions and then use those columns in conditional split.

    SELECT CASE 
            WHEN Email LIKE '%@%'
                OR Email LIKE '%~%'
                THEN 'bad data'
            ELSE 'good data'
            END AS emaildatatype
        ,*
    FROM [table]
WHERE Email LIKE '%~%'
        OR NOT (Email LIKE "%@%")
        OR SUBSTRING(CONVERT(VARCHAR, DOb, 23), 1, 2) <= 12
        OR SUBSTRING(CONVERT(VARCHAR, DOb, 23), 4, 2) <= 31
        OR SUBSTRING(CONVERT(VARCHAR, DOb, 23), 7, 4) <= YEAR(GETDATE());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM