Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Copy a Data in a Row then Insert to Another Row
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

4 Posts

Posted - 10/17/2012 :  10:06:51  Show Profile  Reply with Quote
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 9901
0210 480000 20121017 000001 NULL

I 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

Edited by - leinad28 on 10/17/2012 10:10:51

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 10/17/2012 :  23:40:23  Show Profile  Reply with Quote

SET t.InstCode = t1.InstCode 
FROM table t
INNER JOIN table t1
ON t1.ProcessCode = t.ProcessCode 
AND t1.Date = t.Date 
AND t1.TraceNumber = t.TraceNumber 
AND t.InstCode IS NULL

SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000