Ramco Ramco

Ramco Ramco

  • 422
  • 3.4k
  • 513.6k

what rowcount means

Aug 19 2024 1:54 PM

Hi

 In below Stored Procedure what @@rowcount means

Create PROCEDURE [dbo].[sp_Department]
    @Action VARCHAR(1)
    ,@EntryNo int = Null
    ,@Description VARCHAR(50) = NULL
    ,@ShortName VARCHAR(25) = NULL
    ,@Success BIT OUTPUT
AS
BEGIN
    SET NOCOUNT ON;

    --INSERT
    IF @Action = 'I'
    BEGIN
        INSERT INTO dbo.Department(Description, createdon, updatedon)
        VALUES (@Description, GETDATE(), GETDATE())
        SET @Success = 1
    END

    --DELETE
    IF @Action = 'D'
    BEGIN
        UPDATE dbo.Department
        SET status = 0, updatedon = GETDATE() WHERE docentry = @EntryNo
        SET @Success = 1
    END

    IF @@ROWCOUNT = 0
        SET @Success = 0
END

Thanks


Answers (1)