declare @deptfullname varchar(100)
select a.deptid , @deptfullname = d1.orgName+d2.orgName
from DeptInfo a
left join OrgInfo d1 on a.Org1 = d1.OrgId left join OrgInfo d2 on a.Org2 = d2.OrgId
where a.DeptId=154
错误提示:A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.
要达到这个效果该怎么改呢?谢谢了!
------解决方案--------------------
select a.deptid ,deptfullname = d1.orgName+d2.orgName
from DeptInfo a
left join OrgInfo d1 on a.Org1 = d1.OrgId
left join OrgInfo d2 on a.Org2 = d2.OrgId
where a.DeptId=154
------解决方案--------------------
declare @deptfullname varchar(100)
select @deptfullname = d1.orgName+d2.orgName
from DeptInfo a
left join OrgInfo d1 on a.Org1 = d1.OrgId left join OrgInfo d2 on a.Org2 = d2.OrgId
where a.DeptId=154