• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

Update table

hi,
I need to update a table called "MyTable", this table has several columns but one of the columns may contain blanks sometime and i want to populate the blanks with onother column's data.  Here is how it look like my table:

ID                  NAME           TP_NAME            LOCATION
20                 ABC                LLM12                   NC
40                 MOX                XX14                     WA
25                 MMX                                              AZ
88                 XXX                                               OH
45                 LLP                 MO56                      KS

So in this case, since TP_NAME for ID 25 is blank i would like to update it with the same data as the NAME (MMX).  After the update, my table should look like this:
20                 ABC                LLM12                   NC
40                 MOX                XX14                     WA
25                 MMX                MMX                       AZ
88                 XXX                 XXX                       OH
45                 LLP                 MO56                      KS
0
karinos57
Asked:
karinos57
2 Solutions
 
Aneesh RetnakaranDatabase AdministratorCommented:
update MyTable
set TP_NAME    = Name
where tp_name is NULL or TP_Name  = ''
0
 
waltersnowslinarnoldCommented:
This will do..

update
MyTable
set
TP_NAME    = NAME
where
TP_NAME IS NULL or TP_NAME  = ''
0
 
karinos57Author Commented:
thanks
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now