Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hello,I have a table with the following fields :Name = e.g. Joe BloggsAge = 27DOB = 01/01/1980AreaID = NULLAreaName = North WestEvery person listed in here has aI have another table which lists the areas (ID and Name)1 - North2 - South3 - North Westand so on....I would like to update every person's record in table 1, with their team ID as currently it is null.Obviously I need to get the team ID using table 2 and linking on the name.What would be the syntax for this please ?Thanks in advance
SwePeso
Patron Saint of Lost Yaks
30421 Posts
Posted - 2007-10-15 : 06:51:28
update xset x.areaid = y.idfrom table1 as xinner join table2 as y on y.name = x.areanameE 12°55'05.25"N 56°04'39.16"
khtan
In (Som, Ni, Yak)
17689 Posts
Posted - 2007-10-15 : 06:52:18
[code]UPDATE pSET areaid = a.idFROM person p INNER JOIN area aON p.areaname = a.nameWHERE p.areaid IS NULL[/code]KH[spoiler]Time is always against us[/spoiler]
khtan
In (Som, Ni, Yak)
17689 Posts
Posted - 2007-10-15 : 06:53:11
! where is the alert ? KH[spoiler]Time is always against us[/spoiler]
Jonny1409
Posting Yak Master
133 Posts
Posted - 2007-10-15 : 06:57:58
Thanks Peso and Khtan
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2007-10-15 : 07:23:55
quote:Originally posted by khtan ! where is the alert ? KH[spoiler]Time is always against us[/spoiler]
Your color coding tool takes lot of time MadhivananFailing to plan is Planning to fail
khtan
In (Som, Ni, Yak)
17689 Posts
Posted - 2007-10-15 : 07:27:10
yeah, slow by 50 secondsKH[spoiler]Time is always against us[/spoiler]