October 8, 2024 at 7:01 pm
Hi friends. how can i fix that?
;with cte
as
(select distinct(e.Id )
from SecurityKmsAbfa..EnterprisePositions e
join SecurityKmsAbfa..Import_UsersTeh i on e.Name=i.vahedeSazmani
join NewKmsAbfa..Members m on m.SSN=i.kodeMelli
)
update SecurityKmsAbfa..users
set EnterprisePositionId = (select id from cte )
from SecurityKmsAbfa..Import_UsersTeh i
join NewKmsAbfa..Members m on m.SSN=i.kodeMelli
join SecurityKmsAbfa..users u on u.Id=m.id
where u.EnterprisePositionId is null
October 8, 2024 at 7:52 pm
If the following query produces more than one result, that is your problem – you cannot update a single value to a multi-valued result set:
SELECT DISTINCT
(e.Id)
FROM SecurityKmsAbfa..EnterprisePositions e
JOIN SecurityKmsAbfa..Import_UsersTeh i
ON e.Name = i.vahedeSazmani
JOIN NewKmsAbfa..Members m
ON m.SSN = i.kodeMelli
Note that the double-dot notation is considered bad practice. Unless you have a reason (other than laziness) for omitting the schema name, it should be included.
If you tell us what you are trying to do, we might be able to fix your query, but as there are a few tables involved, I'd rather not guess.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy