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

Select table name

 
   Database Help (Home) -> Datamining RSS
Next:  Christmas Shopping Made Easy  
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: 103



(Msg. 2) Posted: Thu Dec 20, 2007 7:54 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" <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)

 >> Stay informed about: Select table name 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Running a SQL query - table include FROM and TO columns - I am trying to export some calendar data from a sql table. This table has 2 column names "from" and "to" for the time range of the appointment. When I run the sql query: select date, from, to, act_code, mat_code, clt_code, notes, de...

Collation Problem any help - Hello all : My problem is like the following I have an online databse with a latin collation, this database is using ntext and nvarchar values that was with our previous admin ok the problem is in the data is stored should use another collation (the...

Reprocessing a mining model - I'm currently developing a user registration prototype. The aim is to classify certain types of users. However, after the registration I query a decision tree model in Analysis Services with DMX and I want to send the user data into the warehouse to....

Trying to cut down query times - I have a query that is based on two other queries that are based on tables in a database. All of the queries that are used for this final query use grouping and totals. In the application I am making, I need to choose a date range to select the subset....

Update serial number in database - Hi, I want to update specific fields in a existing table in SQL database as below example: L240100001-LG L240100002-LG *serial number is difficult to update one by one L240100003-LG L240100004-LG L240100005-LG change to L240100001-L L240100002-L..
   Database Help (Home) -> Datamining All times are: Pacific Time (US & Canada) (change)
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 ]