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 |
kwacz23
Starting Member
44 Posts |
Posted - 2013-09-13 : 09:42:37
|
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 2008select *from [Sales].[Customer] cjoin [Person].[Person] p on c.[PersonID] = p.[BusinessEntityID]join Person.BusinessEntity e on p.BusinessEntityID = e.BusinessEntityIDjoin Person.BusinessEntityAddress bea on e.BusinessEntityID = bea.BusinessEntityIDjoin person.Address a on a.AddressID = bea.AddressIDRegards |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2013-09-13 : 10:00:20
|
[code]UPDATE aSET a.xxx = 'yyy'FROM Person.Address AS aINNER JOIN Person.BusinessEntityAddress AS bea ON bea.AddressID = a.AddressIDINNER JOIN Person.BusinessEntity AS e ON e.BusinessEntityID = bea.BusinessEntityIDINNER JOIN Person.Person AS p ON p.BusinessEntityID = e.BusinessEntityIDINNER JOIN Sales.Customer AS c ON c.[PersonID] = p.[BusinessEntityID];[/code] Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
djj55
Constraint Violating Yak Guru
352 Posts |
Posted - 2013-09-13 : 12:04:45
|
You might need WHERE a.xxx IS NULL djj |
|
|
|
|
|