Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UDT (Table) problem with join

Status
Not open for further replies.

thendrickson

Programmer
Apr 14, 2004
226
US
I have reduced a more complex problem to the simplest elements in the following selects.

my select using a join does not return any data while the select using a sub select returns data as expected

I have researched this forum as well as BOL and am finding nothing that explains where I am off track

Either I have tunnel vision and am missing something very basic or I do not understand a UDT table. Can somebody help?

[blue]

DECLARE @Input dbo.tbl_serial --USER DEFINED type table

--fill UDT with TEST data
Insert into @Input Select distinct T.OriginalUserOrdNo ,T.OriginalRelease, T.Serial from dbo.table1 T1

--Verify test data is present
select * from @input order by serial

--Test SELECT with join fails
select distinct t1.col1, t1.col2, t.Serial
from dbo.Table1 t1
INNER join @Input I
on
t1.Serial = I.Serial

--returns expected records
select distinct t1.col1, t1.col2, t.Serial
from dbo.Table1 t1
where t.Serial in(Select distinct serial from @Input)

[/blue]

 
You missed one [1]
Code:
 --Test SELECT  with join fails
select distinct t1.col1, t1.col2, t[COLOR=red][b]1[/b][/color].Serial
from   dbo.Table1  t1
INNER join @Input  I on t1.Serial = I.Serial

Borislav Borissov
VFP9 SP2, SQL Server 2000,2005 & 2008.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top