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
 Query with Update and Join

Author  Topic 

jplayford
Starting Member

2 Posts

Posted - 2008-07-01 : 09:38:36
Hey Everyone --

Fairly new to SQL, so still trying to perfect my syntax here...

I have a query below (in that query I want to update multiple fields....I want to update the status_id to 2, set the term_dttm to today, set the modification_dttm to today, and

select claimants.person_id, claims.claim_id, claims.status_id, claims.term_dttm,
claims.modification_dttm from claimants
left outer join claims on claims.claimant_id = claimants.claimant_id where group_id = 'XXXX'

Can anyone help me properly format this to run in query analyzer?

Thanks in advance,

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2008-07-01 : 11:53:15
Im not so sure I understand which table you are trying to update. If it's the claims table and you want to update only the status_id, term_dttm and modification_dttm then.....


UPDATE claims
SET
[status_id] = 2
, [term_dttm] = getDate()
, [modification_dttm] = getDate()
WHERE
<primary key> IN (
SELECT
claims.<primary key>
FROM
claimants
left outer join claims on claims.claimant_id = claimants.claimant_id
where
group_id = 'XXXX'
)



If that's not what you want please post your table structure and give us a bit more information..

Charlie.

-------------
Charlie
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-01 : 12:40:57
quote:
Originally posted by jplayford

Hey Everyone --

Fairly new to SQL, so still trying to perfect my syntax here...

I have a query below (in that query I want to update multiple fields....I want to update the status_id to 2, set the term_dttm to today, set the modification_dttm to today, and

select claimants.person_id, claims.claim_id, claims.status_id, claims.term_dttm,
claims.modification_dttm from claimants
left outer join claims on claims.claimant_id = claimants.claimant_id where group_id = 'XXXX'

Can anyone help me properly format this to run in query analyzer?

Thanks in advance,



UPDATE claims
SET status_id=2,
term_dttm=GETDATE(),
modification_dttm=GETDATE()
WHere your conditions if any


didnt uunderstand what posted select statement was for??
Go to Top of Page
   

- Advertisement -