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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:00:25+00:00 2026-05-23T08:00:25+00:00

I have a procedure for a table in my database, but it doesn’t seem

  • 0

I have a procedure for a table in my database, but it doesn’t seem to do what I want it to. Could someone check if I am doing it wrong? I am new to SQL all together.

This is my procedure.
It is supposed to change admin status from 1 to 0 and from 0 to 1 when I tell it to. But for some reason it changes it and doesn’t change it back 🙁

ALTER PROCEDURE [sesuser].[Login_Admin_Toggle]
(
    @loginID INT
)

AS
BEGIN

DECLARE @tmpId INTEGER;

SET @tmpId = (SELECT SESAdmin FROM [ses_users].[sesuser].[SESLogin] WHERE SESLoginID = @loginID);

IF (@tmpId = 1)
BEGIN
    SET @tmpId = 0
    RETURN
END
ELSE
    SET @tmpId = 1

UPDATE [ses_users].[sesuser].[SESLogin]
SET SESAdmin = @tmpId   
WHERE SESLoginID = @loginID

END
  • 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-23T08:00:26+00:00Added an answer on May 23, 2026 at 8:00 am

    Alex K is completely right. You set your variable to 0 then RETURN, meaning that you never get to the UPDATE statement from there.

    But, on a slight tangent, you can actually do all of that in one statement…

    BEGIN
    
      UPDATE [ses_users].[sesuser].[SESLogin]
      SET SESAdmin = 1 - SESAdmin
      WHERE SESLoginID = @loginID
    
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to (loosely) have a stored procedure like select * from table where
Let's say I have information in a table that is in the wrong database
I have written stored procedure to poll the data from the database in biztalk.but
i have a procedure in which i am inserting record in employee table.nad getting
I have a stored procedure that returns values from a temp table. In my
I have a simple procedure that selects 1000 rows from a table. For the
I have a stored procedure that ideally should be able to accept a list/table
I have a db2 table with certain columns. I have a stored procedure for
I have problems filling a temporary table with the resultset from a procedure call
I have a raw table used as a kind of buffer where periodically new

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.