Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a two table one name is "user" and another name is "Prod".

My query is
SQL
update User_list_SQL set team=s.uteam, S.flag='Y' 
from User_list_SQL as U, SQlVal as S 
where U.name=S.uname

the error comes the following

[SQL Server]The multi-part identifier "S.flag" could not be bound.

How to write the query the above instance? please advice. Thanks
Posted
Updated 3-Mar-14 22:54pm
v2

1 solution

use two diffrent queries like bellow
SQL
update u set team=s.uteam
from User_list_SQL as U, SQlVal as S
where U.name=S.uname

SQL
update s set S.flag='Y'
from User_list_SQL as U, SQlVal as S
where U.name=S.uname

because,
you can not update multiple table in one single update statement.. what you can do is wrap the update statement in a transaction, commit changes only when both update are successful
visit link...
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/eab6e48d-d22a-4e1f-add6-aaf3b47bdd84/how-to-update-multiple-tables-in-sql-server-2008-?forum=transactsql[^]
Happy Coding!
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900