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 |
|
helixpoint
Constraint Violating Yak Guru
291 Posts |
Posted - 2005-01-13 : 22:13:49
|
| I have 2 tables. I need to update a field in table 1 from a field in table two. Here is the tricky part...Table two has 3 fields UnitCode, UnitName and StateTable one has 3 fields QuestionID, OptionText and OptionOtherA concatinated state and unitname from table 2 was added to optionsText in table one. They were supposed to add UnitCode to OptionOther at the same time , but did not. How can I do this now and be accurate. Here is an example of the tables:Table1:USA-MA-AA-MD-103-1-IL Lexington Market / Store MDUSA-MA-AA-MD-109-1-IL Security Square Mall / Store MDUSA-MA-AA-MD-110-1-IL St. Charles Towne Center / Store MDTable2:33 MD, Lexington Market / Store 033 MD, Security Square Mall / Store 033 MD, St. Charles Towne Center / Store 0 |
|
|
tuenty
Constraint Violating Yak Guru
278 Posts |
Posted - 2005-01-14 : 14:15:41
|
I haven't tested but I think it'll workUpdate table1Set OptionOther = UnitCode Where exists( Select 1 from table2 Where optionsText=State+UnitName ) .*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.A candle loses nothing by lighting another candle |
 |
|
|
amachanic
SQL Server MVP
169 Posts |
Posted - 2005-01-14 : 15:05:19
|
| What do you want your tables to look like at the end of this update? And which columns are which? Can you lay out the data a bit better? I can't tell where one ends and the next begins. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|