I have query which returns single value (i.e) count. I'm exceuting it using the stored procedure in the following way and using execute reader with dataset to get single value
CREATE PROCEDURE GetCnt
@EmpNo char(4)
AS
BEGIN
SET NOCOUNT ON;
Declare @Cnt int
SELECT @Cnt = count(*)
FROM employees
WHERE EMPLNO = @EmpNo
AND test = 'p'
BEGIN
SELECT @Cnt
END
END
is this effcient way or Do I need to use the execute.scalar() and return value directly from the query instead of assigning to @cnt can any one advise me