ahmed elbarbary

ahmed elbarbary

  • NA
  • 1.6k
  • 275.3k

How to make status update when only value site assembly exist on temp

Jul 29 2020 9:50 PM
I work on SQL server 2012 Query I face issue : I can't Update status when at Least one Assembly Site
Record on temp table #rev Matched temp table #location based on Revision Id .
Expected Result is :
  1. Revision Id Status  
  2. 1900 Found  
  3. 2000 Not Found  
  4. 5000 Found  
 
as Example
Revision Id 1900 status Will be Found because Revision Id 1900 on temp #rev equal LocRevisionId on temp
#location and Assembly Site on temp #rev equal locAssemblySiteId on temp #location at least one .
AND
Revision Id 2000 status Will be Not Found because Revision Id 2000 on temp #rev equal LocRevisionId on
temp #location and Assembly Site on temp #rev Not equal locAssemblySiteId on temp #location at least one .
  1. create table #rev  
  2. (  
  3. RevisionId int,  
  4. AssemblySiteId int,  
  5. Status nvarchar(200)  
  6. )  
  7. insert into #rev(RevisionId,AssemblySiteId)  
  8. values  
  9. (1900,200),  
  10. (2000,300),  
  11. (5000,800)  
  12. create table #location  
  13. (  
  14. locRevisionId int,  
  15. locAssemblySiteId int  
  16. )  
  17. insert into #location(locRevisionId,locAssemblySiteId)  
  18. values  
  19. (1900,200),  
  20. (1900,150),  
  21. (2000,290),  
  22. (2000,310),  
  23. (5000,800),  
  24. (5000,820)  

Answers (1)