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.
Author |
Topic |
Ats
Starting Member
32 Posts |
Posted - 2009-04-05 : 07:47:37
|
Hi i am trying to update data in one of my tables with new data i have recieved, Firstly I have a table called compliance it has about 10 columns I need to update data in just 2 of the columns, also it takes 2 fields to get the unique identifier. the structure of the compliance table is PermitidyearverifiedAllocationsurrenderedcereruThis is the original table structure with the permit id and year fields being used as the unique identifier.The structure of the table which has the new data is as follows and is called newdataPermitidyearverifiedAllocationSo I want to update the verified and allocation in the compliance table withe the data in the new data table. I also want to state if the data in the new data table is = 0 then dont update. I have been trying to do this but it is not working very well, I keep seeing different versions on the net and im not sure of which one to use.any help would be appreciated |
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-04-05 : 16:29:10
|
Can you try this..update aset a.verified = case when b.verified <> 0 then b.verified end, a.Allocation = case when b.Allocation <> 0 then b.Allocation endfrom compliance a inner join newdata bon a.Permitid = b.Permitid and a.year = b.year |
|
|
|
|
|