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 |
|
OldMySQLUser
Constraint Violating Yak Guru
301 Posts |
Posted - 2007-12-21 : 14:55:49
|
| I have two tables:table 1-------codedescriptioncoloursizeactivetable 2-------codelocationsales_regionactiveHow can I, using SQL Server 2005, update both tables so thatcolour = redlocation = Wisconsinsize = mediumactive = yeswhere code = AL1please?table 1 has code as the primary key. table 2 has no index. |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2007-12-21 : 14:57:46
|
| What have you tried so far?[Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQL or How to sell Used CarsFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2007-12-21 : 15:00:19
|
| UPDATE Table1SET colour = 'red',size = 'medium',active = 'yes'WHERE code ='AL1'UPDATE Table2SET location = 'Wisconsin',active = 'yes'WHERE code ='AL1' |
 |
|
|
OldMySQLUser
Constraint Violating Yak Guru
301 Posts |
Posted - 2007-12-21 : 15:50:30
|
Many thanks guys. My newbie brain did not realise that you can have more than one update operation per query. |
 |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2007-12-22 : 02:50:21
|
| You could wrap some transaction management around your 2 update statements. You could also look at TRIGGERSJack Vamvas--------------------Search IT jobs from multiple sources- http://www.ITjobfeed.com |
 |
|
|
|
|
|