Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 551487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:23:57+00:00 2026-05-13T11:23:57+00:00

Say we have stored procedure(s) performing simple operations like this: CREATE PROCEDURE [dbo].[AddNewAuthorReturnID] (

  • 0

Say we have stored procedure(s) performing simple operations like this:

CREATE PROCEDURE [dbo].[AddNewAuthorReturnID]
(   
    @Author_Name VARCHAR(MAX),
    @Author_ID int OUTPUT
)
AS
    SET NOCOUNT OFF;
BEGIN
    INSERT INTO AUTHORS (@Author_Name)
    VALUES (@Author_Name)
    SET @Author_ID = SCOPE_IDENTITY()
    
    SELECT @Author_ID
 END

In the above procedure, the returned id is an indication of successful operation.

Consider the equivalent with DELETE.

CREATE PROCEDURE [dbo].[DeleteAuthor]
(       
    @Author_ID int 
)
AS
    SET NOCOUNT OFF;
BEGIN
    DELETE FROM AUTHORS 
    WHERE
    (Author_ID = @Author_ID)
END
  • How can we know the operation was
    successful and the AUTHORS record was
    succesfully removed if we use the above
    procedure ?
  • With an update operation?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:23:57+00:00Added an answer on May 13, 2026 at 11:23 am

    You could select @@rowcount

    It will show you the rows affected.

    e.g

    CREATE PROCEDURE [dbo].[DeleteAuthor]
    (       
        @Author_ID int 
    )
    AS
        SET NOCOUNT OFF;
    BEGIN
     DELETE FROM AUTHORS 
     WHERE
     (Author_ID = @Author_ID)
     SELECT @@ROWCOUNT 
    END
    

    This can be applied to update too.

    CREATE PROCEDURE [dbo].[UpdateAuthor]
    (       
        @Author_ID int 
    )
    AS
        SET NOCOUNT OFF;
    BEGIN
     UPDATE AUTHORS 
        SET AuthorName = 'John'
     WHERE
     (Author_ID = @Author_ID)
     SELECT @@ROWCOUNT 
    END
    

    Alternatively you could use @@Error and raise an error id @@rowcount > 1 (if you only wanted to update one row).

    e.g

    CREATE PROCEDURE [dbo].[DeleteAuthor]
    (       
        @Author_ID int 
    )
    AS
        SET NOCOUNT OFF;
    BEGIN
     DELETE FROM AUTHORS 
     WHERE
     (Author_ID = @Author_ID)
    
     IF @@ROWCOUNT <>1
     BEGIN
      RAISERROR ('An error occured',10,1)
      RETURN -1
     END
    END
    

    As Giorgi says this will be returned as a returncode.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a simple stored procedure that looks like this (note: this
Let say I have a simple Stored Procedure: ALTER PROCEDURE [dbo].[myProc] AS BEGIN SELECT
I have a stored procedure that looks like: CREATE PROCEDURE dbo.usp_TestFilter @AdditionalFilter BIT =
Say I have this great query in my stored procedure. Select * from Temp
Let's say we have a stored procedure selecting something from a table: CREATE PROCEDURE
Lets say I have a stored procedure which has a simple IF block. If
Say I have a stored procedure consisting of several separate SELECT, INSERT, UPDATE and
Let's say I have a stored procedure in Microsoft SQL Server 2005 that returns
I have a stored procedure with multiple insert/select statements. Let's say I'm using the
let's say I have HTML stored in HTMLElement object. It's outerHTML property looks like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.