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

  • Home
  • SEARCH
  • 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 3454010
In Process

The Archive Base Latest Questions

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

I have the SQL below and want to update the managerNTID with @managerNTID only

  • 0

I have the SQL below and want to update the managerNTID with @managerNTID only if the users DB record has StopManagerOverride value of 0, if it is set to 1 on the record then I don’t want to update this field:

UPDATE ee
SET 
    MangerId        = CASE ee.ShopManagerOverride
                            WHEN 0 THEN @MangerId
                            ELSE ee.MangerId
                          END
    ,ManagerNTID        = CASE ee.ShopManagerOverride
                            WHEN 0 THEN @managerNTID
                            ELSE ee.ManagerNTID
                          END
    ,NTID               = @NTID
    ,FirstName          = @FirstName
    ,LastName           = @LastName
    ,FullName           = @FullName
    ,ReportingGroup     = @ReportingGroup
    ,DistinguishedName  = @DistinguishedName
    ,IsActive           = 1
    --,StopManagerOverride= 1
    ,LastUpdate         = GETDATE()
    ,UpdateBy           = @UpdateBy
FROM dbo.Employees ee
    Inner Join dbo.Employees e ON e.NTID = ee.NTID
WHERE ee.NTID = @NTID

Thoughts on how to make this one field in the update have an inline condition?

edit: i am almost there, just need to resolve some ambiguous columns now. my eyes are red from this already.

  • 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-18T09:26:32+00:00Added an answer on May 18, 2026 at 9:26 am

    You could try something like this – if the ShopManagerOverride is set to 1, update it to the parameter value passed in, otherwise update it to the value it already has (I’m also assuming your field is really ManagerId – not MangerId – right??):

    UPDATE 
        dbo.Employees
    SET 
        ManagerId = @ManagerId,
        ManagerNTID = CASE e.ShopManagerOverride
                         WHEN 1 THEN @managerNTID
                         ELSE e.ManagerNTID
                      END,
        NTID = @NTID,
        FirstName = @FirstName,
        LastName = @LastName,
        FullName = @FullName,
        ReportingGroup = @ReportingGroup,
        DistinguishedName = @DistinguishedName,
        IsActive = 1,
        LastUpdate = GETDATE(),
        UpdateBy = @UpdateBy
    FROM
        dbo.Employees e 
    WHERE 
        e.NTID = dbo.Employees.NTID
        AND dbo.Employees.NTID = @NTID
    

    Untested, straight and “free hand” from my brain – hope I got the syntax right! Try it – does it work, does it do what you’re looking for??

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

Sidebar

Related Questions

I have an SQL query that takes the following form: UPDATE foo SET flag=true
I have an SQL server database that I am querying and I only want
I have a sql query shown below i want to use the variables streetname,
SQL Server (2005/2008) Each of the below statements have the same result. Does anyone
How can I have SQL repeat some set-based operation an arbitrary number of times
I am a newbie to SQL. please help with this. I have the below
I have an update statement in SQL server where there are four possible values
I have a SQL query where I want to insert multiple rows in single
I have an SQL table defined as below: CREATE TABLE [TestComposite] ( ID int,
I have the sql below but can not get it to work select product_category,

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.