Quantcast
Viewing latest article 5
Browse Latest Browse All 6

issue with @@rowcount

Hello, You did not mention ELSE that is why you are getting the same results

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

Viewing latest article 5
Browse Latest Browse All 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>