search
Twitter Rss Feeds
MicrosoftArticlesForumsGroups
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml/Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

Web ProgrammingArticlesForumsGroups
JavaScript
ASP
ASP.NET
Web Services

Non-MicrosoftArticlesForumsGroups
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

DatabasesArticlesForumsGroups
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsGroups
Microsoft Excel
Microsoft Word
Microsoft Powerpoint
Publisher
Money

Operating SystemsArticlesForumsGroups
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsGroups
Share Point
BizTalk
Site Server
Exhange Server
IIS
Transaction Server

Graphic DesignArticlesForumsGroups
Macromedia Flash
Adobe PhotoShop
Microsoft Expression

OtherArticlesForumsGroups
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Reviews
Search Engines
Resumes

 

Previous Thread:   Deploying Analysis Services Project: "Errors in the encryption library"

6/29/2005 11:29:03 AM    Re: SQL Query question for selection from multiple tables
[forwarding to a more appropriate newsgroup -  
  
microsoft.public.sqlserver.server]  
  
--  
  
-Raman Iyer  
  
SQL Server Data Mining  
  
[This posting is provided "AS IS" with no warranties, and confers no  
  
rights.]  
  
"Vasilis X" <someone@somewhere.com> wrote in message  
  
news:O0VSadKfFHA.1284@TK2MSFTNGP14.phx.gbl...

6/29/2005 11:43:17 AM    Re: SQL Query question for selection from multiple tables
This should do:  
  
select *  
  
from (  
  
select *  
  
from T1  
  
union all  
  
select *  
  
from T2  
  
union all  
  
select *  
  
from T3) TB  
  
where ID>100 and ID < 200  
  
-- and F20>1000  
  
--  
  
-oj  
  
"Raman Iyer [MS]" <ramaniy@online.microsoft.com> wrote in message  
  
news:%23TQXuhNfFHA.3460@TK2MSFTNGP10.phx.gbl...

6/29/2005 1:30:20 PM    Re: SQL Query question for selection from multiple tables
Yes. It just requires more typing. ;-)  
  
My original derived table should be converted to a partitioned view. Then,  
  
the optimizer should be able to use the index and only do IO on the table  
  
that has data.  
  
e.g.  
  
create view _v  
  
as  
  
select *  
  
from T1  
  
union all  
  
select *  
  
from T2  
  
union all  
  
select *  
  
from T3  
  
go  
  
select *  
  
from _v  
  
where ...  
  
--  
  
-oj  
  
"Quentin Ran" <remove_this_qran2@yahoo.com> wrote in message  
  
news:O2hXjROfFHA.2496@TK2MSFTNGP15.phx.gbl...

6/29/2005 2:54:39 PM    Re: SQL Query question for selection from multiple tables
oj, can this be better:  
  
select column_list from T1 where ID_column > 100 and ID_column < 200  
  
union all  
  
select column_list from T2 where ID_column > 100 and ID_column < 200  
  
union all  
  
select column_list from T3 where ID_column > 100 and ID_column < 200  
  
Quentin  
  
"oj" <nospam_ojngo@home.com> wrote in message  
  
news:e5ZeqpNfFHA.3164@TK2MSFTNGP15.phx.gbl...

6/29/2005 3:03:39 PM    SQL Query question for selection from multiple tables
Hello.  
  
Here's the question :  
  
1 database, lets call it "Data"  
  
3 data tables, T1, T2, T3  
  
All tables have the same columns : ID, F1, F2, ... Fm  
  
How will i select fields F1, F2,...,Fn from all tables with a common for all  
  
tables limitation on ID, eg:  100< ID < 200 ?  
  
If i want an additional crieteria, eg: F20>1000 how will i do it?  
  
What are the SQL commands in both cases?  
  
I hope the problem is understood.  
  
I am using SQL Server 2000 and VB.net  
  
Thanks in advance,  
  
Vasilis.


Pete's Blog   |    Pete's Resume   |    Robbe's Blog   |    Robbe's Resume   |    Archive #2   |    Archive #3   |    Dotnetslackers   |    XmlPitStop   |    Advertise   |   Contact Us   |   Privacy   |   Copyright (c) 2000 - 2009 eggheadcafe.com  All rights reserved.