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 |
|
sqlchiq
Posting Yak Master
133 Posts |
Posted - 2008-08-12 : 20:23:36
|
| is it possible to do something like this....I'm trying to update an entire section of a column that has incomplete dates. Basically every date with executiontime of 8/8/2008 has incomplete dates. I have to match it up with entries from another day to get the complete day.basically the saildate column looks like thisApr 23Apr 23Jan 1Feb 4But it should beApr 23, 2009Apr 23, 2010Jan 1, 2009Feb 4, 2009There are other entries in the same table with the correct dates, so I'm trying to update these older incomplete entries with the newer complete ones.I've tried the following...update carnysrockset t1.saildate = t2.saildatefrom carnysrock as t1, carnivalcleaned as t2where t2.executiontime = '08/12/2008' and t1.interiorprice = t2.interiorprice and t1.balconyprice = t2.balconyprice and t1.oceanviewprice = t2.oceanviewpriceand left(t1.saildate, 6) = left(t2.saildate,6) and t1.shipname = t2.shipnameandUPDATE carnysrock as t1SET t1.saildate = (SELECT t2.saildateFROMcarnivalcleaned as t2WHERE t2.executiontime = '08/12/2008' and t1.interiorprice = t2.interiorprice and t1.balconyprice = t2.balconyprice and t1.oceanviewprice = t2.oceanviewpriceand left(t1.saildate, 6) = left(t2.saildate,6) and t1.shipname = t2.shipname)I can't seem to get it to work, does anyone have any ideas?? |
|
|
jason7655
Starting Member
24 Posts |
Posted - 2008-08-15 : 11:13:24
|
quote: Originally posted by sqlchiq is it possible to do something like this....I'm trying to update an entire section of a column that has incomplete dates. Basically every date with executiontime of 8/8/2008 has incomplete dates. I have to match it up with entries from another day to get the complete day.basically the saildate column looks like thisApr 23Apr 23Jan 1Feb 4But it should beApr 23, 2009Apr 23, 2010Jan 1, 2009Feb 4, 2009There are other entries in the same table with the correct dates, so I'm trying to update these older incomplete entries with the newer complete ones.I've tried the following...update carnysrockset t1.saildate = t2.saildatefrom carnysrock as t1, carnivalcleaned as t2where t2.executiontime = '08/12/2008' and t1.interiorprice = t2.interiorprice and t1.balconyprice = t2.balconyprice and t1.oceanviewprice = t2.oceanviewpriceand left(t1.saildate, 6) = left(t2.saildate,6) and t1.shipname = t2.shipnameandUPDATE carnysrock as t1SET t1.saildate = (SELECT t2.saildateFROMcarnivalcleaned as t2WHERE t2.executiontime = '08/12/2008' and t1.interiorprice = t2.interiorprice and t1.balconyprice = t2.balconyprice and t1.oceanviewprice = t2.oceanviewpriceand left(t1.saildate, 6) = left(t2.saildate,6) and t1.shipname = t2.shipname)I can't seem to get it to work, does anyone have any ideas??
Can you provide the script to create the table and an example of a good row and a bad row? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-15 : 11:39:31
|
| How are the two tables related by? What are primary keys of each? |
 |
|
|
|
|
|
|
|