|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I wonder if you can offer some assistance with this query.
I need to query a table in SQL2000 to read the value in one column and populate a new column with new data. For example: If Column A = ABC in table Class_001 I need a query statement to populate Column Z with 123 If Column A = XYZ in table Class_001 I need a query statement to populate Column Z with 789 Your help would be much appreciated. |
|
#2
|
||||
|
||||
|
Code:
update Class_001
set Z = case when A = 'ABC'
then 123
else 789 end
where A in ('ABC','XYZ')
rudy http://r937.com/ |
|
#3
|
|||
|
|||
|
Many thanks for your quick reply.
Your query works but I have changed it slightly as I would like to populate Test with different data depending on the data in PN This is my effort..... Is there an easier way? ![]() update Class_021 set Test = '1' where PN = '3001' update Class_021 set Test = '2' where PN = '3002' update Class_021 set Test = '3' where PN = '3003' |
|
#4
|
||||
|
||||
|
heck no, that looks fine
|
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Query one column to populate another |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|