BEGIN
SELECT COUNT(*) FROM TBL2
RETURN @@ROWCOUNT
Heading
if @@ROWCOUNT = 0
PRINT '*** Source file empty ***'
GOTO
END
BEGIN
SELECT COUNT(*) FROM TBL2
RETURN @@ROWCOUNT
if @@ROWCOUNT = 0
PRINT '*** Source file empty ***'
GOTO
END
Use NOT EXISTS to check for existance of rows
IF NOT EXISTS (SELECT * FROM TBL2)
BEGIN
TRUNCATE TABLE TBL1
INSERT INTO TBL1 ( . . . )
SELECT . . .
FROM TBL2
END
ELSE
BEGIN
PRINT '*** Source file empty ***'
END