Thursday, 12 September 2013

Understanding of SQL Stored Procedure

Understanding of SQL Stored Procedure

Create PROCEDURE alertCount
(
@field1 VARCHAR(200),
@field2 INT,
@field3 INT,
@field4 INT,
@field5 INT,
@field6 INT,
@noOfCount INT OUT
)
AS
BEGIN
SELECT @noOfCount = COUNT(*) from tableA
END
I'm very new to stored procedure and based on some tutorial, the code
above helps me to create a procedure (I hope it works fine).
Declare @noOfCount as INT
Exec usp_AlertCount asd, 1, 1, 1, 1, 1, @noOfCount
select @noOfCount
Now the above code suppose to return me 9 as there are 9 rows of records
in my tableA but its returning me null instead. May I know what's wrong
with it?
P/S: Please don't bother about the logic. I'm just trying to understand a
very simple stored procedure. Thank You.

No comments:

Post a Comment