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 |
|
rossmac1
Starting Member
2 Posts |
Posted - 2003-04-04 : 07:42:54
|
Hi,Is there any easy way to return the source table name of a record in a query - I'm using UNION to concatenate multiple Selects from different identically structured tables and it would be really great if I could insert a column that shows which source table each record comes from......Query looks like this:select Name from Customer1 union allselect Name from Customer2union allselect Name from Customer3ThanksRoss |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2003-04-04 : 07:50:08
|
| select 1, Name from Customer1 union all select 2, Name from Customer2 union all select 3, Name from Customer3 might be a simple way to solve your problem |
 |
|
|
rossmac1
Starting Member
2 Posts |
Posted - 2003-04-04 : 08:04:41
|
| Thanks Andrew,Simple, succinct but why couldn't I see it?Doh..... |
 |
|
|
|
|
|