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.
Author |
Topic |
cas_o
Posting Yak Master
154 Posts |
Posted - 2008-07-24 : 05:38:43
|
[code]create table tbPrimary( dbPk int identity(1,1) primary key, dbPAttr varchar(32) NOT NULL )GOcreate table tbForeign ( dbFk int not null, dbFAttr varchar(32) not null, )GOinsert into tbPrimary(dbPAttr) select 'P_One' UNION ALLselect 'P_Two'UNION ALLselect 'P_Three'UNION ALLselect 'P_Four'UNION ALLselect 'P_Five'GOinsert into tbForeign(dbFk, dbFAttr)select 1, 'F_One' UNION ALLselect 1, 'F_Two' UNION ALLselect 2, 'F_One' UNION ALLselect 3, 'F_One' GOselect pk.dbPAttr, isnull(sub.FKAttr, 'No FK Attr') as FKAttr1, coalesce(sub.FKAttr, 'No FK Attr') as FKAttr2 from tbPrimary pk left join ( select distinct p.dbPk, 'Has FK Attr' as FKAttr from tbPrimary p join tbForeign f on p.dbPk = f.dbFk ) sub on pk.dbPk = sub.dbPk order by pk.dbPKSQL Server 2000 - RESULTS :dbPAttr FKAttr1 FKAttr2 -------------------------------- ----------- ----------- P_One Has FK Attr Has FK AttrP_Two Has FK Attr Has FK AttrP_Three Has FK Attr Has FK AttrP_Four Has FK Attr No FK AttrP_Five Has FK Attr No FK Attr(5 row(s) affected)SQL Server 2005 RESULTS : dbPAttr FKAttr1 FKAttr2-------------------------------- ----------- -----------P_One Has FK Attr Has FK AttrP_Two Has FK Attr Has FK AttrP_Three Has FK Attr Has FK AttrP_Four No FK Attr No FK Attr P_Five No FK Attr No FK Attr (5 row(s) affected)[/code]wtf?;-]... Quack Waddle |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-07-24 : 06:15:03
|
I get correct result for both 2000 and 2005.Microsoft SQL Server 2000 - 8.00.2039 (Intel X86) May 3 2005 23:18:38 Copyright (c) 1988-2003 Microsoft Corporation Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 2)Microsoft SQL Server 2005 - 9.00.3233.00 (Intel X86) Mar 6 2008 22:09:47 Copyright (c) 1988-2005 Microsoft Corporation Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 3) E 12°55'05.25"N 56°04'39.16" |
 |
|
cas_o
Posting Yak Master
154 Posts |
Posted - 2008-07-24 : 06:21:14
|
Aha! I have developer edition of 2000 but with same service pack.Microsoft SQL Server 2000 - 8.00.194 (Intel X86) Aug 6 2000 00:57:48 Copyright (c) 1988-2000 Microsoft Corporation Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 2)My 2005 installation is:Microsoft SQL Server 2005 - 9.00.3068.00 (Intel X86) Feb 26 2008 18:15:01 Copyright (c) 1988-2005 Microsoft Corporation Express Edition on Windows NT 5.1 (Build 2600: Service Pack 2)cas_o AKA Holly Styles, Paul Alcon;-]... Quack Waddle |
 |
|
cas_o
Posting Yak Master
154 Posts |
Posted - 2008-07-24 : 06:21:55
|
I still think this sucks though :)cas_o AKA Holly Styles, Paul Alcon;-]... Quack Waddle |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
cas_o
Posting Yak Master
154 Posts |
Posted - 2008-07-24 : 07:02:06
|
[code]Microsoft SQL Server 2000 - 8.00.2039 (Intel X86) May 3 2005 23:18:38 Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 2)SQL Server 2000 RESULTS : dbPAttr FKAttr1 FKAttr2-------------------------------- ----------- -----------P_One Has FK Attr Has FK AttrP_Two Has FK Attr Has FK AttrP_Three Has FK Attr Has FK AttrP_Four No FK Attr No FK Attr P_Five No FK Attr No FK Attr (5 row(s) affected)[/code]Sorted. Thanks!cas_o AKA: Holly Styles, Paul Alcon ;-]... Quack Waddle |
 |
|
|
|
|
|
|