I have two tables top1 and top2 .First I want to check top1 is empty or not.If top1 is not empty then truncate top2 and insert data from top1. Otherwise dont do any action .
CASE
WHEN top1 is not empty THEN
Truncate top2
Insert from Top1
END case
SELECT COUNT(*) FROM table_nameif this return 0 means your table is empty.IF EXISTS (SELECT * FROM Table)...