Solved

Using OUTPUT with UPDATE

Posted on 2012-04-05
2
347 Views
Last Modified: 2012-06-22
I have the following code that is giving me an error "Incorrect syntax near OUTPUT." I have not found any examples that combine the use of a JOIN and the FROM clause in the UPDATE, so maybe that is the problem, but any assistance would be appreciated.

UPDATE TOP(1) t1
SET	col1 = t2.col3
FROM	Table1 t1
INNER JOIN Table2 t2
ON	t1.ID = t2.ID
OUTPUT	INSERTED.ID INTO @Updated
WHERE	t2.col4 = 10

Open in new window

0
Comment
Question by:dbbishop
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 39

Accepted Solution

by:
appari earned 500 total points
ID: 37814708
try this

UPDATE TOP(1) t1
SET      col1 = t2.col3
OUTPUT      INSERTED.ID INTO @Updated
FROM      Table1 t1
INNER JOIN Table2 t2
ON      t1.ID = t2.ID
WHERE      t2.col4 = 10
0
 
LVL 15

Author Closing Comment

by:dbbishop
ID: 37814745
THANKS!!!!
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how the fundamental information of how to create a table.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question