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
 Database Design and Application Architecture
 Update Query

Author  Topic 

richcol
Starting Member

5 Posts

Posted - 2007-03-26 : 06:16:53
Hi all,
could someone give me advice on how to finish this update query?

Update Tempclm
set status = 99 where

select Clm.Date, Ggr.Code from Clm
inner join Cli
on Clm.clid = cli.clid
inner join Ggr
on Clm.AID = Ggr.AID
where exists
(select ref, Clmdate from TempClm
where ref = Ggr.Code
and clmdate = Cli.ClmDate)

I basically want the update to set the status column to 99 where the code and date match for each row returned by the select query.
At the moment it is just updating all rows with the value 99.

any ideas appreciated.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-26 : 06:20:29
I have no idea how to bind the two queries together, but the basic idea is this

UPDATE x1
SET x1.Status = 99
FROM Table1 AS x1
INNER JOIN Table2 AS x2 ON x2.SomeCol = x1.SomeCol


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -