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 |
|
ajay_hk
Starting Member
4 Posts |
Posted - 2008-04-28 : 13:42:23
|
Hi all,I have a table called "dimcustomer" which has 25 columns in it out of which account name is one of them. There is another table called "dw_Organisation" which comes from a different source which also has the account name in it. There are about 15K rows in the "Dimcustomer" table where the account names are nulls. I want to use the account names in the "dw_Organisation" table to update the account names in the "Dimcustomer" table. The join info and SQL i'm using is as given below...UPDATE dimcustomer SET account = (SELECT b.nameFROM dimcustomer a, tibcostg..dw_organisation bwhere a.GUID = b.commonid and a.account is null) WHERE EXISTS (SELECT b.nameFROM dimcustomer a, tibcostg..dw_organisation bwhere a.GUID = b.commonid and a.account is null) The above SQL throws me the following error... quote: Server: Msg 512, Level 16, State 1, Line 1Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.The statement has been terminated.
It would be really helpful if you could advice me on where things are going wrong on the above SQL...Many thanks for your help. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-28 : 13:48:55
|
| Try this:UPDATE aSET account = b.nameFROM dimcustomer aINNER JOIN tibcostg..dw_organisation bON a.GUID = b.commonidWHERE a.account IS NULLTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-28 : 13:49:55
|
| [code]UPDATE aSET a.account = b.nameFROM dimcustomer aINNER JOIN tibcostg..dw_organisation bON a.GUID = b.commonid WHERE a.account is null [/code] |
 |
|
|
ajay_hk
Starting Member
4 Posts |
Posted - 2008-04-28 : 13:56:27
|
| That worked...Many thanks for your help @tkizer and @visakh16. |
 |
|
|
|
|
|