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 |
|
chapo
Starting Member
39 Posts |
Posted - 2008-05-20 : 11:54:59
|
What I'm trying to do is update the blank records of the Finish field with the one main record that stores the Finish code.sample dataproject|dwg|mark|finish|quan|date|type|main07-324|B1210|B1210|GAL|2|2/29/2008|W|TRUE07-324|B1210|1393||1|2/29/2008|L|FALSE07-324|B1210|1393||1|null|L|FALSE07-324|B1210|2010||3|2/29/2008|W|FALSE07-324|B1210|2011||2|2/29/2008|L|FALSE07-324|B1210|fb0994|F|1|2/29/2008|HS|FALSE07-324|A1100|A1100|1|7|2/28/2008|W|TRUE07-324|A1100|20||2|2/28/2008|PL|FALSEwould likeproject|dwg|mark|finish|quan|date|type|main07-324|B1210|B1210|GAL|2|2/29/2008|W|TRUE07-324|B1210|1393|GAL|1|2/29/2008|L|FALSE07-324|B1210|1393|GAL|1|null|L|FALSE07-324|B1210|2010|GAL|3|2/29/2008|W|FALSE07-324|B1210|2011|GAL|2|2/29/2008|L|FALSE07-324|B1210|fb0994|F|1|2/29/2008|HS|FALSE07-324|A1100|A1100|1|7|2/28/2008|W|TRUE07-324|A1100|20|1|2|2/28/2008|PL|FALSEThe best way I thinck is for the records that the finihs is blank grab the dwg value and where it matches the mark value grab the finish from that one record and applied it to all matches. I have to update thousands of records for different projects so any help would be helpfull. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-20 : 12:05:18
|
| [code]UPDATE t1SET t1.finish=t2.finishFROM (SELECT * FROM YourTable WHERE ISNULL(finish,'') = '')t1INNER JOIN (SELECT * FROM YourTable WHERE ISNULL(finish,'') <> '')t2ON t2.project=t1.projectAND t2.dwg=t1.dwg[/code]I'm assuming you will always have only a single record for each project,dwg combination with a valid value for finish and rest all will be blank. |
 |
|
|
|
|
|