| Author |
Topic |
|
lamujerdetuhermano10
Yak Posting Veteran
75 Posts |
Posted - 2008-08-19 : 18:32:23
|
| how do u update rose 5.6 to 1?thanksdeclare @computersNV table (computerID int, computerName varchar(50), computerPrice varchar(30))insert @computersNVselect 1, 'Rose', $1 union all--select 2, 'Richard', $5 union all--select 3, 'Mayo', $2 union allselect 4, 'Manuel', $8declare @computersCA table (computerID int, computerName varchar(50), computerPrice money)insert @computersCAselect 1, 'Rose', $5.6 union all--select 2, 'Richard', $7.5 union all--select 3, 'Mayo', $4 union allselect 4, 'Manuel', $8 /*Select CA.computerPrice, NV.computerPricefrom @computersCA CAleft join @computersNV NVon CA.computerPrice = NV.computerPricewhere NV.computerPrice is null*/select * from @computersCAupdate @computersCAset CA.computerPrice = NV.computerPrice from @computersCA CAleft join @computersNV NVon CA.computerPrice = NV.computerPricewhere NV.computerPrice is nullselect * from @computersCA |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-08-19 : 18:34:26
|
| Welcome funketekun/gongxia649/escaleraroyal/lamujerdetuhermano10/etc...!!!! |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
lamujerdetuhermano10
Yak Posting Veteran
75 Posts |
Posted - 2008-08-19 : 18:38:49
|
| seems like this forum is not taking the post seriously. |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-08-19 : 18:39:22
|
quote: Originally posted by lamujerdetuhermano10 seems like this forum is not taking the post seriously.
    |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
lamujerdetuhermano10
Yak Posting Veteran
75 Posts |
Posted - 2008-08-19 : 18:43:34
|
| i just want to update the records that do not exists in the first table with the value from the second table. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-08-19 : 18:51:55
|
| I'm confused when you say "do not exist".Could you show us what data should appear in both tables after the update runs?Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog |
 |
|
|
lamujerdetuhermano10
Yak Posting Veteran
75 Posts |
Posted - 2008-08-19 : 19:06:08
|
| table1 table21 5.63 3outputtable1 table21 13 3 |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-08-19 : 19:28:42
|
| I don't understand your output.Show us exactly what these should return:select * from @computersCAselect * from @computersNVTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog |
 |
|
|
lamujerdetuhermano10
Yak Posting Veteran
75 Posts |
Posted - 2008-08-19 : 19:45:11
|
| declare @computersNV table (computerID int, computerName varchar(50), computerPrice varchar(30))insert @computersNVselect 1, 'Rose', $1 union allselect 2, 'Richard', $5 union allselect 3, 'Mayo', $2 union allselect 4, 'Manuel', $8declare @computersCA table (computerID int, computerName varchar(50), computerPrice money)insert @computersCAselect 1, 'Rose', $5.6 union allselect 2, 'Richard', $7.5 union allselect 3, 'Mayo', $4 union allselect 4, 'Manuel', $8 /*Select CA.computerPrice, NV.computerPricefrom @computersCA CAleft join @computersNV NVon CA.computerPrice = NV.computerPricewhere NV.computerPrice is null*/select * from @computersCAselect * from @computersNV |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
lamujerdetuhermano10
Yak Posting Veteran
75 Posts |
Posted - 2008-08-19 : 19:58:26
|
| computerid computername computerprice1 Rose 1.002 Richard 5.003 Mayo 2.004 Manuel 8.00computerid computername computerprice1 Rose 5.602 Richard 7.503 Mayo 4.004 Manuel 8.00 |
 |
|
|
lamujerdetuhermano10
Yak Posting Veteran
75 Posts |
Posted - 2008-08-19 : 19:59:13
|
| im thinking this cannot be done on sql |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-08-20 : 12:38:09
|
| I'm thinking you don't know how to ask a question properly. This is very easy in SQL Server, but I can't waste my time anymore on this thread.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-08-22 : 03:58:30
|
quote: Originally posted by lamujerdetuhermano10 how do u update rose 5.6 to 1?thanksdeclare @computersNV table (computerID int, computerName varchar(50), computerPrice varchar(30))insert @computersNVselect 1, 'Rose', $1 union all--select 2, 'Richard', $5 union all--select 3, 'Mayo', $2 union allselect 4, 'Manuel', $8declare @computersCA table (computerID int, computerName varchar(50), computerPrice money)insert @computersCAselect 1, 'Rose', $5.6 union all--select 2, 'Richard', $7.5 union all--select 3, 'Mayo', $4 union allselect 4, 'Manuel', $8 /*Select CA.computerPrice, NV.computerPricefrom @computersCA CAleft join @computersNV NVon CA.computerPrice = NV.computerPricewhere NV.computerPrice is null*/select * from @computersCAupdate @computersCAset CA.computerPrice = NV.computerPrice from @computersCA CAleft join @computersNV NVon CA.computerPrice = NV.computerPricewhere NV.computerPrice is nullselect * from @computersCA
Your update should beupdate @computersCAset CA.computerPrice = NV.computerPrice from @computersCA CAjoin @computersNV NVon CA.computerID = NV.computerIDMadhivananFailing to plan is Planning to fail |
 |
|
|
|