Declare myvar int Set myvar = Dts.Variables["User::theID"].Value SELECT * FROM dbo.myTable where (myTableId in (SELECT (CASE myTableId WHEN 0 THEN max(myTableId) ELSE myTableId END)))
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)