Why don't you simply use string constants, like
SELECT 'table1' AS TableName, * FROM table1
UNION ...
--
Dejan Sarka
http://blogs.solidq.com/EN/dsarka/default.aspx
"IndrekS" <IndrekS DeleteThis @discussions.microsoft.com> wrote in message
news:0D1F2662-23D2-43BB-A188-0F263FCAE574@microsoft.com...
> How can I select 'table name' in select clause if I use UNION ALL?
> Example:
> select * from table1
> union all
> select * from table2
> union all
> select * from table3
>
> Now I want to see the tablename from where I'll get data.
> Ex:
> select x, * from table1 -- x - funtion/... that gives the table name
> (table1)