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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:50:48+00:00 2026-05-18T00:50:48+00:00

Need to INNER JOIN a resultset returned by UPDATE OUTPUT with another table and

  • 0

Need to INNER JOIN a resultset returned by UPDATE OUTPUT with another table and return results. Is it possible?

Here is a small example:

CREATE TABLE [dbo].[Customers]
(   
   [CustomerId] [int],   
   [CustomerName]  [nvarchar](50)
)
GO

CREATE TABLE [dbo].[Orders]
(   
   [OrderId] [int],   
   [OrderName]  [nvarchar](50)
)
GO

CREATE TABLE [dbo].[CustomerOrders]
(   
   [CustomerId] [int],   
   [OrderId]  [int]
)
GO

INSERT INTO CustomerOrders (CustomerId, OrderId) VALUES (1, 1)
INSERT INTO CustomerOrders (CustomerId, OrderId) VALUES (1, 2)
INSERT INTO CustomerOrders (CustomerId, OrderId) VALUES (2, 1)
GO

Need to update OrderId on CustomerOrders table and return names of the customers, all in 1 shot. So far I can only return CustomerIds:

UPDATE CustomerOrders SET OrderId=NULL 
OUTPUT Deleted.CustomerId
WHERE OrderId='1'
  • 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-18T00:50:48+00:00Added an answer on May 18, 2026 at 12:50 am

    TSQL/SQL Server 2005+ supports JOINs in the UPDATE clause – see the documentation:

    UPDATE CUSTOMERORDERS
       SET orderid = NULL
    OUTPUT c.customername
      FROM CUSTOMERORDERS co
      JOIN CUSTOMERS c ON c.customerid = co.customerid
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following table: compare . I need to do an inner join
I need a way to join a table with a function's results. I'm not
I need to create dynamic INNER JOIN (I believe I need to anyway). I
I want to inner join with a child table based on ID and get
The reason I need the inner class to be non static is because I
I have outer div and inner div. I need to place inner div at
I need to pass the $route to its inner function,but failed: function compilePath( $route
I need to create a service in .NET that maintains (inner) state in-memory, spawns
I have a div with some inner content that I need to have an
Are anonymous inner classes private by default? Can I make them public? I need

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.