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 |
|
kostlin
Starting Member
2 Posts |
Posted - 2007-04-02 : 04:19:09
|
| I have two colums within the same table. The 1st column contains name of products and the second column is used to rename the products so not every row is entered (omly those products we want to rename). I would like to create a new column which updates the name of the products. So if there is no new name it uses the old one, but if there is a new name use that one. I hope this makes sence? |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-04-02 : 04:24:11
|
| Table Structures, Sample Data and expected output, please.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
kostlin
Starting Member
2 Posts |
Posted - 2007-04-02 : 04:57:54
|
| Product name, New Product name, Restulting Product name to useCCG, , CCGELNETT, ,Elnettie, ElnettieELV STY, , ELV STYSTUDIO, , STUDIOELVIVE, , ELVIVEMEN, ,Mens, MensI have the first 2 columns but woudl like to create the resulting column.I hope this is understandable? |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-04-02 : 05:03:05
|
| [code]declare @t table( prodname varchar(50), newprodname varchar(50), result varchar(50))insert @t(prodname, newprodname)select 'CCG', '' union allselect 'ELNETT', 'Elnettie' union allselect 'ELV STY', '' union allselect 'Studio', '' union allselect 'ELVIVE', '' union allselect 'Men', 'Mens'update @tset result = coalesce(nullif(newprodname, ''), prodname)select * from @t[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|
|
|
|