无法绑定多部分标识符“S.flag” [英] The multi-part identifier “S.flag” could not be bound

查看:75
本文介绍了无法绑定多部分标识符“S.flag”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表,一个名字是用户,另一个名字是Prod。



我的查询是

< pre lang =SQL> update User_list_SQL set team = s.uteam,S.flag = ' Y'
来自 User_list_SQL < span class =code-keyword> as U,SQlVal as S
其中 U.name = S.uname



错误来自以下



[SQL Server]无法绑定多部分标识符S.flag。



如何编写上述实例的查询?请指教。谢谢

解决方案

使用两个不同的查询,如bellow

 更新 u  set  team = s.uteam 
来自 User_list_SQL as U,SQlVal as S
其中 U .name = S.uname



  update  s  set  S.flag = '  Y' 
< span class =code-keyword> from User_list_SQL as U,SQlVal as S
其中 U.name = S.uname



因为,

您无法在一个单独的更新语句中更新多个表。您可以做的是将update语句包装在事务中,提交更改只有当两个更新都成功时

访问链接...

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 [ ^ ]

快乐编码!

:)


I have a two table one name is "user" and another name is "Prod".

My query is

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

解决方案

use two diffrent queries like bellow

update u set team=s.uteam
from User_list_SQL as U, SQlVal as S
where U.name=S.uname


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!
:)


这篇关于无法绑定多部分标识符“S.flag”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆