all groups > sql server programming > august 2004 >
You're in the

sql server programming

group:

Update when condition is met


Update when condition is met Aleks
8/7/2004 11:43:50 PM
sql server programming:
I need to run this update


Update
Cases
set archived = 2

But only on records found with this query ...

Select * from
Cases
Inner join processstep
ON cases.PROCESSSTEP = processstep.ProcessstepID
where processstep.Processtep LIKE '%closed%'

How can I do this ?

Aleks

Re: Update when condition is met Aleks
8/8/2004 12:30:18 AM
Excellent .. this worked just fine.

A


[quoted text, click to view]

Re: Update when condition is met Hari Prasad
8/8/2004 9:42:08 AM
Hi,

This is one method:-

Update Cases
set archived = 2
where PROCESSSTEP in (select ProcessstepID from processstep where Processtep
LIKE '%closed%')

Thanks
Hari
MCDBA


[quoted text, click to view]

Re: Update when condition is met David Portas
8/8/2004 11:09:43 AM
UPDATE Cases
SET archived = 2
WHERE EXISTS
(SELECT *
FROM ProcessStep
WHERE processstepid = Cases.processstep
AND processstep LIKE ' %closed%')

A good naming convention is to use the same name whenever an attribute
appears in more than one table. On this basis you would presumably have used
the name "processstepid" for the column in Cases to avoid confusion with the
column "processstep" in the ProcessStep table, which apparently is a
different attribute altogether in this case.

--
David Portas
SQL Server MVP
--

AddThis Social Bookmark Button