Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL 2000 Intersect Equivalent

Posted on 2006-10-30
3
Medium Priority
?
512 Views
Last Modified: 2008-01-09
I am looking for a way to get an intersection of 2 tables in a SQL Server 2000 database.  I know 2005 offers this functionality built in, but 2000 lacks this.  I'm guessing there is still a way to accomplish this with what 2000 does offer, probably with some tricky subqueries, but I haven't been able to figure it out yet.

Basically I have 2 tables that have a CaseNumber field and I want to get a recordset that lists the CaseNumbers that appear in both table1 and table2.  Anyone have some SQL code lying around that will accomplish this?  Thanks in advance.
0
Comment
Question by:porkVT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Expert Comment

by:srafi78
ID: 17835555
Select * from Table1 t1 where t1.CaseNumber in (Select CaseNumber from Table2)
UNION ALL
Select * From Table2 t2 where t1.CaseNumber in (Select CaseNumber from Table1)
0
 
LVL 8

Accepted Solution

by:
srafi78 earned 500 total points
ID: 17835561
Syntax error...

Select * from Table1 t1 where t1.CaseNumber in (Select CaseNumber from Table2)
UNION ALL
Select * From Table2 t2 where t2.CaseNumber in (Select CaseNumber from Table1)
0
 
LVL 11

Expert Comment

by:regbes
ID: 17835699
Hi srafi78,

try this

select distinct table1.casenumber
from table1 inner join table 2 on table1.casenumber = table2.casenumber

0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how the fundamental information of how to create a table.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question