Hello, You did not mention ELSE that is why you are getting the same results
please check this
please check this
DECLARE @A int BEGIN SELECT @A = (SELECT A FROM #tab WHERE A=1) IF @@ROWCOUNT = 0 BEGIN PRINT 'no data found' END Else PRINT 'PERFORM OTHER ACTION' END Go DECLARE @A int BEGIN SELECT @A = (SELECT A FROM #tab WHERE A=2) IF @@ROWCOUNT <> 0 BEGIN PRINT 'no data found' END Else PRINT 'PERFORM OTHER ACTION' END