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 2008 Forums
 Transact-SQL (2008)
 Update field value with value from same field, but

Author  Topic 

rusmanicai
Starting Member

13 Posts

Posted - 2011-12-23 : 11:39:24
Hello,
I have a weird situation where I need to look at a table and display a field value if condition 1 is met or pull value from a different record if condition 2 is met.
Below is my formula but I get 'Department Unknown' on everything that meets condition 2. I have no clue how to fix this or if it is even possible to populate same field with values from same field, same table.
Your help is appreciated.
Thank you,
Julia.

--here I select all records for which I need to update UserDefined1 field

select * from OrderComponent
where OrderComponent.LotNumber<>''
order by JobNumber

--this is my attempt to update the field:)
update OrderComponent
set UserDefined1=UserDefined1
where OrderComponent.LotNumber=OrderComponent.JobNumber

RJulia

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-23 : 12:22:44
with some sample data, explain how you want update to perform

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -