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
 General SQL Server Forums
 New to SQL Server Programming
 Update a column if the case has a parent_id

Author  Topic 

carau2007
Starting Member

31 Posts

Posted - 2012-02-08 : 10:11:03
Hi,

Below is my table. I need to update a table that will insert the File_ID in the File_Parent_ID column only if the case has a File_parent_Number that corresponds to File_Number. How do I do this?

Example: Row 13 should have a 12 in File_Parent_ID

File_ID / File_Number / File_Parent_Number / File_Parent_ID
12-----------1004
13-----------1005-------------1004

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-02-08 : 10:17:55
[code]
update t
set File_Parent_ID = p.File_ID
from yourtable t
inner join yourtable p on t.File_Parent_Number = p.File_Number
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

carau2007
Starting Member

31 Posts

Posted - 2012-02-08 : 11:06:00
Thanks!
Go to Top of Page
   

- Advertisement -