Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Select table name

 
   Database Forums (Home) -> Datamining RSS
Next:  Memory error when creating a DB procedure  
Author Message
IndrekS

External


Since: Dec 19, 2007
Posts: 1



(Msg. 1) Posted: Wed Dec 19, 2007 2:28 am
Post subject: Select table name
Archived from groups: microsoft>public>sqlserver>datamining (more info?)

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)

 >> Stay informed about: Select table name 
Back to top
Login to vote
Dejan Sarka

External


Since: Mar 18, 2004
Posts: 317



(Msg. 2) Posted: Thu Dec 20, 2007 5:08 am
Post subject: Re: Select table name [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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" wrote in message

> 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)

 >> Stay informed about: Select table name 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Select and sub select - Hi, I was wondering if I could get some help with the query below. The idea is to list the incomes generated by every agent per month. The query works however; one of the agents (Agent_ID = 35) has sub agents. The latter have assigned an additional I...

select into - Is there a way to create a table using something similar to 'select ..... into' in a dmx query?

SELECT in sections - I want to know how to retrieve records from a SELECT command in sections. I mean, if total records of a SELECT command is 100,000, I want to use SELECT that retrieves me them in 20 "sections" of 5000 : first 5000, second 5000, sixth 5000 or ...

Select Sum Group By - Hi. I have the following scenario.. TABLE1= sale.accom TABLE2= sale.meals TABLE3= sale.other I would like to get the Sum(price) of all 3 table and match against a client. I would just like to know the official way of doing this before I implement..

Select N rows and min - Dear All I need your help to sove this problem. I have a table Customers_Bal containing the following Information: Date Balance 01/01/2007 1000 01/02/2007 700 01/03/2007 800 01/04//2007 600 01/05/2007 1200..
   Database Forums (Home) -> Datamining All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]