You are here: Re: searching a list of tables, derived from another table « MsSQL Server « IT news, forums, messages
Re: searching a list of tables, derived from another table

Posted by Erland Sommarskog on 10/20/91 11:27

calan (none@nospam.com) writes:
> So back to the original question, is there an SQL example of this? I'm
> not having any luck finding anything on using a subquery in a FROM
> clause that returns a list of table names.

And you will never have. There is no indirection on table names in T-SQL.
In fact there is very little indirection at all in T-SQL. And for a good
reason.

> I thought something simple like this would work (This assumes that all
> tables listed in "MyTables" will have a field called "Configured".):
>
> SELECT t2.TableName, t1.Configured
> FROM (SELECT TableName FROM MyTables AS t2) t1
>
> But it doesn't....

Either you loop that table and build the list with dynamic SQL, or
you hard-code each table. I would recommend the latter.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация