Solved

Using OUTPUT with UPDATE

Posted on 2012-04-05
2
344 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
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

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.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now