Discussion:
Select table name
(too old to reply)
IndrekS
2007-12-19 10:28:01 UTC
Permalink
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)
Dejan Sarka
2007-12-20 06:54:36 UTC
Permalink
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
Post by IndrekS
How can I select 'table name' in select clause if I use UNION ALL?
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.
select x, * from table1 -- x - funtion/... that gives the table name
(table1)
Loading...