SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Complicated update
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kwacz23
Starting Member

44 Posts

Posted - 09/13/2013 :  09:42:37  Show Profile  Reply with Quote
Hi

I would like to add fake address for all customer which whey do not have ( I would like to use one query). This was excercise I got.


this is query what helping me basing is from Adevnture works 2008
select *
from [Sales].[Customer] c
join [Person].[Person] p on c.[PersonID] = p.[BusinessEntityID]
join Person.BusinessEntity e on p.BusinessEntityID = e.BusinessEntityID
join Person.BusinessEntityAddress bea on e.BusinessEntityID = bea.BusinessEntityID
join person.Address a on a.AddressID = bea.AddressID

Regards

SwePeso
Patron Saint of Lost Yaks

Sweden
30241 Posts

Posted - 09/13/2013 :  10:00:20  Show Profile  Visit SwePeso's Homepage  Reply with Quote
UPDATE		a
SET		a.xxx = 'yyy'
FROM		Person.Address AS a
INNER JOIN	Person.BusinessEntityAddress AS bea ON bea.AddressID = a.AddressID
INNER JOIN	Person.BusinessEntity AS e ON e.BusinessEntityID = bea.BusinessEntityID
INNER JOIN	Person.Person AS p ON p.BusinessEntityID = e.BusinessEntityID
INNER JOIN	Sales.Customer AS c ON c.[PersonID] = p.[BusinessEntityID];



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

djj55
Constraint Violating Yak Guru

USA
329 Posts

Posted - 09/13/2013 :  12:04:45  Show Profile  Reply with Quote
You might need
WHERE a.xxx IS NULL


djj
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000