0

What is @@rowcount and with small code snippet explain the usage?
Is the foll. code is rite--
Create procedure get_emp_count ( @emp_id int) As Select * from emp where
emp_id =@emp_id
If @@rowcount = 0
Begin
Select 'no rows with emp_id= ' Select @emp_id
End .

Can u pls explain the above code.

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by rayofhope
0

What is @@rowcount and with small code snippet explain the usage?
Is the foll. code is rite--
Create procedure get_emp_count ( @emp_id int) As Select * from emp where
emp_id =@emp_id
If @@rowcount = 0
Begin
Select 'no rows with emp_id= ' Select @emp_id
End .

Can u pls explain the above code.

Hi yogesh,

@@rowcount returns the number of rows affected by sql statement.

the line : If @@rowcount = 0 checks if rows are returned by your select statement.


if no, procedure returns no rows with emp_id= the empid you passed to the procedure

HTH

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.