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 |
leinad28
Starting Member
4 Posts |
Posted - 2012-10-17 : 10:06:51
|
Hi guys,I'm stuck.Need some help about copying a data in a row then insert this data in another row when the field is blank or null. See sample data below:MsgType ProcessCode Date TraceNumber InstCode 0200 480000 20121017 000001 99010210 480000 20121017 000001 NULLI need only to copy the data on field InstCode then insert this in NULL row below.I'm confused if what could be the best way to do it. Will appreciate a lot for some inputs. Thanks |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-10-17 : 23:40:23
|
[code]UPDATE tSET t.InstCode = t1.InstCode FROM table tINNER JOIN table t1ON t1.ProcessCode = t.ProcessCode AND t1.Date = t.Date AND t1.TraceNumber = t.TraceNumber WHERE t1.InstCode IS NOT NULLAND t.InstCode IS NULL[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|