I was wondering if it is possible to have an UPDATE satement inside a
SELECT statment. What I want to do is select certian rows from a table
then based on the result I want to update another table. Metaphorically
something like the following
SELECT A.QTY,(UPDATE TABLE B SET QTY=A.QTY WHERE B.[ID]=A[ID]) FROM
TABLE A
*** Sent via Developersdex http://www.examnotes.net ***Hi,
Looks like you are trying to Select and Update the contents of the table in
one go.
Try to use a Stored Procedure for this purpose.
Hope this answered your Question.
thanks,
Chandra
"Hussain Al-Dhaheri" wrote:
> I was wondering if it is possible to have an UPDATE satement inside a
> SELECT statment. What I want to do is select certian rows from a table
> then based on the result I want to update another table. Metaphorically
> something like the following
> SELECT A.QTY,(UPDATE TABLE B SET QTY=A.QTY WHERE B.[ID]=A[ID]) FROM
> TABLE A
>
> *** Sent via Developersdex http://www.examnotes.net ***
>|||Hi
No, you vannot do it in that way
[Untested]
UPDATE TableA SET col=(SELECT b.col FROM TableB b WHERE b.col=col)
WHERE EXISTS (SELECT * FROM TableB b WHERE b.col=col)
SELECT <column lists> FROM
"Hussain Al-Dhaheri" <hdhaheri@.hotmail.com> wrote in message
news:e4s4e1tSFHA.3672@.TK2MSFTNGP10.phx.gbl...
> I was wondering if it is possible to have an UPDATE satement inside a
> SELECT statment. What I want to do is select certian rows from a table
> then based on the result I want to update another table. Metaphorically
> something like the following
> SELECT A.QTY,(UPDATE TABLE B SET QTY=A.QTY WHERE B.[ID]=A[ID]) FROM
> TABLE A
>
> *** Sent via Developersdex http://www.examnotes.net ***sql
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment