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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 need help with update statement

Author  Topic 

csphard
Posting Yak Master

113 Posts

Posted - 2003-12-05 : 12:57:43
I am using a case to update an item because i do not know how many items i will update. It works however i want to update to fields based on the case. this line gives me a syntax error todate,datetobefiled = case due_evals_id can anyone tell me what i am doing wrong. I've included the entire statement below.

update due_evals
set ext_updated_by = '919999',
ext_updated_date = '12/5/2003 9:49:47 AM',
todate,datetobefiled = case due_evals_id
when 255584 then '03/30/2004','2/28/2004' END,
ext_hist_todate = case due_evals_id
when 255584 then '06/30/2003' END where due_evals_id in (255584)

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-12-05 : 13:07:45
There are a few problems. You haven't set todate equal to anything. Also, you have two values in the THEN part of the CASE statement. You can't do that. Perhaps if you explained more we'd be able to help. This version compiles fine for me:


update due_evals
set ext_updated_by = '919999',
ext_updated_date = '12/5/2003 9:49:47 AM',
datetobefiled = case
when due_evals_id = 255584 then '03/30/2004'
END,
ext_hist_todate = case
when due_evals_id = 255584 then '06/30/2003'
END
where due_evals_id = 255584



Tara
Go to Top of Page
   

- Advertisement -