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)
 Simple update

Author  Topic 

duhaas
Constraint Violating Yak Guru

310 Posts

Posted - 2007-06-25 : 10:35:13
trying to update a table using the following:


use IMCMFTP
update RES_ATTR
set RES_CODE =
case RES_CODE
when 'SR1' then 'SR1____'
when 'SR2' then 'SR2____'
when 'SR3' then 'SR3____'
end;
where RES_CODE in ('SR1','SR2','SR3')


doesnt appear i have my where syntax in the proper location, i essentially want to only update the records that have those RES_CODES

Ifor
Aged Yak Warrior

700 Posts

Posted - 2007-06-25 : 10:49:29
[code]UPDATE RES_ATTR
SET RES_CODE = RES_CODE + '____'
WHERE RES_CODE in ('SR1','SR2','SR3')[/code]
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-25 : 10:50:51
[code]UPDATE RES_ATTR
SET RES_CODE = CASE RES_CODE
WHEN 'SR1' THEN 'SR1____'
WHEN 'SR2' THEN 'SR2____'
WHEN 'SR3' THEN 'SR3____'
END
WHERE RES_CODE IN ('SR1','SR2','SR3')[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-25 : 10:51:30



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

duhaas
Constraint Violating Yak Guru

310 Posts

Posted - 2007-06-25 : 11:04:00
thanks as always
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-06-25 : 11:04:04
Or just remove the semicolon after the END keyword?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -