Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help

Author  Topic 

nitsmooth
Yak Posting Veteran

68 Posts

Posted - 2010-01-15 : 06:10:52
This is my assignment table

CAllId Resolution
------- -----------
00013182
00013182
00013182
00013182 Completed
00013232
00013232 Completed
00013232
00013232 Completed
00013268
00013268 Completed
00013268 Completed
00013269
00013395
00013449 Completed

What i want is if for a particular callid in assignment table all the reslolution's are completed then mark that callid's resolution in calllog table as completed

How can i do this ...?Can this be done in a single query both checking the assignment table and updating the callLog table

CallLog Table

Callid resolution
------ ----------
00013182
00013232
00013268
.......

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-01-15 : 07:04:29
Assuming that every Callid in assignment has at least one entry in CallLog:
update c
set resolution = 'Completet'
from CallLog c
where not exists (select * from assignment a where a.Callid = c.Callid and a.resolution <> 'Completed')



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-01-15 : 07:23:18
Add

AND resolution <> 'Completed'

to the WHERE clause??

(note typo in the SET statement, I'm sure the O/P can handle that, but there seem to be lots of impetuous folk around who just do Cut&Paste and press GO
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-01-15 : 08:47:06
quote:
Originally posted by webfred

Assuming that every Callid in assignment has at least one entry in CallLog:
update c
set resolution = 'Completed'
from CallLog c
where not exists (select * from assignment a where a.Callid = c.Callid and a.resolution <> 'Completed')
and resolution <> 'Completed'



No, you're never too old to Yak'n'Roll if you're too young to die.


Thanks Kristen


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -