SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 select in update
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

darya
Starting Member

1 Posts

Posted - 09/29/2013 :  14:21:12  Show Profile  Reply with Quote
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

Edited by - darya on 09/29/2013 16:25:12

James K
Flowing Fount of Yak Knowledge

3719 Posts

Posted - 09/29/2013 :  16:59:03  Show Profile  Reply with Quote
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;

Edited by - James K on 09/29/2013 16:59:59
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000