Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 select in update

Author  Topic 

darya
Starting Member

1 Post

Posted - 2013-09-29 : 14:21:12
hi every one, i hope god time

I have two tables,

1st Table is the Table1, Table which has no,l2p.

2nd Table is Table2, Table which has no, DUM

i want update Table1 table
but that update need DUM in Table2 table
so i write select on Table2 in update on Table1
example flow code:

UPDATE Table1
SET
l2p= 0.207 * (SELECT DUM FROM Table2 WHERE [no] < 1389)
WHERE [no] < 1389

this code is not error but this did not work
that select only is working and this update too
but whit both of them update and select do not work

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-09-29 : 16:59:03
update like this:
update t1 set
l2p = 0.207*t2.dum
from
Table1 as t1
inner join Table2 as t2
on t1.no = t2.no
where
t1.[no] < 1389;
Go to Top of Page
   

- Advertisement -