Transact-SQL subqueries using IN statement transformation details
Some parts in the output code are omitted for clarity reasons.
The IN operator checks if an expression is included in the values returned by a subquery.
Source Code
IN -> SqlServer_01.sql
-- Additional Params: -t JavaScriptCREATEPROCEDURE dbo.SP_IN_EXAMPLEASDECLARE @results asVARCHAR(50);SELECT @results =COUNT(*) FROM TABLE1IF @results IN (1,2,3)SELECT'is IN';ELSESELECT'is NOT IN';returnGO-- =============================================-- Example to execute the stored procedure-- =============================================EXECUTE dbo.SP_IN_EXAMPLEGO
Expected Code
OUT -> SqlServer_01.sql
CREATEORREPLACEPROCEDURE dbo.SP_IN_EXAMPLE ()RETURNS STRINGLANGUAGE JAVASCRIPTCOMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"transact"}}'EXECUTEASCALLERAS$$// SnowConvert Helpers Code section is omitted. let RESULTS;SELECT(` COUNT(*) FROM TABLE1`,[],(value) => RESULTS =value);if ([1,2,3].includes(RESULTS)) { } else { }return;$$;-- =============================================-- Example to execute the stored procedure-- =============================================CALL dbo.SP_IN_EXAMPLE();