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 |
|
Kristen
Test
22859 Posts |
Posted - 2006-05-11 : 14:03:29
|
I'm confused! I've seen this a couple of times now:UPDATE TableASET TableAColumn = B.TableBColumnFROM TableA AS A JOIN TableB AS B ON A.ID = B.ID what I'm not sure about is whether, given that the main FROM is "TableA AS A", and thus clearly aliased, whether "UPDATE TableA" is a) valid or b) will cause a Cartesian join!!Thanks,Kristen |
|
|
efelito
Constraint Violating Yak Guru
478 Posts |
Posted - 2006-05-12 : 14:23:21
|
| The update is valid. The update will happen on the rows from TableA that are returned by the from clause. If you are doing an update on on table and say "UPDATE TableA SET TableAColumn = 'foo'" the from is just assumed to be the same as the update. HTHJeff Banschbach, MCDBA |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-05-12 : 14:27:19
|
| Once you use an alias, you don't have to keep using it. So you can use TableA or A. I always use the alias. What's the point of aliasing unless you are going to use it?!!Tara Kizeraka tduggan |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-05-12 : 14:35:30
|
| Ah, so once you use an Alias both the Table name and Alias are valid, but if the Table name is ambiguous you'll get an error, and then you have to use the Alias.But I agree Tara, no point using the Table name once you've aliased it!Kristen |
 |
|
|
|
|
|