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 3216560
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:18:32+00:00 2026-05-17T15:18:32+00:00

BEGIN IF EXISTS(SELECT * FROM Table1 WHERE ID=@ID) BEGIN UPDATE Table1 SET Name=@Name WHERE

  • 0
BEGIN    
 IF EXISTS(SELECT  * FROM Table1 WHERE ID=@ID)      
  BEGIN     
    UPDATE Table1 SET Name=@Name  WHERE ID=@ID    
    SELECT '1'   
  END    
 ELSE     
  SELECT '0'    
END  

Is this the row no. of the table or what ?
Also “IF EXISTS” is checking what ? the table or if the ID exists or not ??

  • 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-17T15:18:32+00:00Added an answer on May 17, 2026 at 3:18 pm

    It looks like whoever wrote that Stored Procedure is using that as a return value to indicate success or failure.

    Doing things that way will result in a single row with a single column being returned for each call to the procedure.

    The correct way to handle this would be to actually use the return value of the stored procedure, rather than returning the single column single row:

    BEGIN
        IF EXISTS(SELECT * FORM Table1 WHERE ID = @ID)
        BEGIN
            UPDATE Table1 SET Name = @Name WHERE ID = @ID
            RETURN 1
        END
    
        RETURN 0
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

IF NOT EXISTS(SELECT * FROM SYS.COLUMNS WHERE Name=N'isHidden' AND Object_ID=Object_ID(N'Templates')) BEGIN BEGIN TRANSACTION GO
I have created a table having three colums GsID,ALlowance and amount Begin if exists(select
I try to delete a row from my table, but when I try I
We have a workorder table. A server agent jobs grabs 100 entries from this
I have multiple levels of the following: IF EXISTS(...) BEGIN IF NOT EXISTS(...) BEGIN
To begin i read all resources from xml in my MergedDictionaries and now I
Be gentle, I'm a SQL newbie. I have a table named autonumber_settings like this:
I have the following Execution statement which creates a table (using data from another
This is about a simple booking/reservation table: key is anId for a timeOfBooking and
In the database I have a table called SERVICE. For this table I have

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.