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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SELECT > Name table

Author  Topic 

shapper
Constraint Violating Yak Guru

450 Posts

Posted - 2007-09-25 : 08:01:03
Hello,

Can a SELECT return records and give that table a name?
So instead of, in my C# code, the tables in the dataset get an index (0,1,2, ...) will get a name (TableA, TableB, ...)

Thanks,
Miguel

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-09-25 : 08:12:50
Not sure if you want this

Select table_name from information_schema.tables

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

aravindt77
Posting Yak Master

120 Posts

Posted - 2007-09-25 : 08:16:24
Hi,

SELECT col1, col2....., '<Table Name>' AS TableName fROM [TABLE]


ARD
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2007-09-25 : 12:48:13
He wants it in the C# code. You can name the tables in C#. Look at your data adapter, or whatever you are using. Its there in the help file.

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

shapper
Constraint Violating Yak Guru

450 Posts

Posted - 2007-09-25 : 13:06:08
I wanted in SQL not in C#.
I know how to do it in C#.

Thanks,
Miguel
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-09-25 : 13:09:27
You need to make your problem more clear then.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -