What is the best way to implement following Teradata logic in Snowflake?
check if incoming stage table has rows. If so, truncate target table, if not, skip (and go to "endofcode", a label not in the example, we just need to skip)
SELECT * FROM ${STAGE}.STAGE_TABLE SAMPLE 1;
.IF ACTIVITYCOUNT = 0 THEN .GOTO endofcode
BEGIN TRANSACTION;
DELETE FROM ${DWH}.TARGET_TABLE ALL;
thank you.
edit: would this work / is best way? :
DELETE FROM targettab WHERE EXISTS (SELECT 1 FROM stagetab sample (1 rows))