Re: Weird One



Sorry, there's a typo, but it still don't woik.
Given a single table:
 
tblAddresses,
 
with records Counted at 800,000 and very clean,
and with these column definitions,
 
inAddress_PSK        INTEGER IDENTITY PK (1,1) (No Nulls, No Doops, PK)
vchAddressLineA     VARCHAR(30) (Not Null Doops OK)
vchAddressLineB     VARCHAR(20) (Nulls OK, Doops OK)
vchCityName            VARCHAR(25)  (No Nulls, Doops OK)
vchStateAbbr            VARCHAR(2) (No Nulls, Doops OK)
vchZipCode              VARCHAR(10) (Nulls OK, Doops OK)
 
 
I wrote the following T-SQL on SQL 2000 SP4
 
SET ANSI_NULLS OFF
GO
SELECT DISTINCT
vchAddressLineA vchTAddressLineA,
vchAddressLineB vchTAddressLineB,
vchCityName vchTCityName,
vchStateAbbr vchTStateAbbr
INTO #tmpNoDoops
FROM tblAddresses
GO
 
I get 480,000 distinct addresses, all well and good. Upon inspection, they look really good.
 
BUT, why does the following query only return 16,520 records???
 
SET ANSI_NULLS OFF
GO
SELECT * FROM tblAddresses JOIN #tmpNoDoops
ON                 
vchAddressLineA = vchTAddressLineA
AND vchAddressLineB = vchAddressLineB
AND vchCityName = vchTCityName
AND vchStateAbbr = vchTStateAbbr
 
IT SHOULD GIVE ME EXACTLY 480,000 Records.
 
I think it has to do with the NULLS in the second address Line, but doesn't ANSI Nulls OFF give me effective INNER JOINS?
 
If I put a WHERE vchAddressLineB IS NOT NULL, I get an exact match, but then I have to do two queries to tie back the records in Temp to the records in Source. NOT DESIRABLE.
 
Anyone?
 
John Smith


Relevant Pages

  • Re: Weird One
    ... "John Smith" <vchAddressLineB IS NOT NULL, I get an exact match, but then I have to do two queries to tie back the records in Temp to the records in Source. ...
    (microsoft.public.sqlserver.clients)
  • Re: Weird One
    ... "John Smith" <"John Smith" <vchAddressLineB IS NOT NULL, I get an exact match, but then I have to do two queries to tie back the records in Temp to the records in ...
    (microsoft.public.sqlserver.clients)
  • Open a query and pausing for changes
    ... I have created a series of queries that alone executed in order work as ... What I am trying to do is execute the set of queries via a command button. ... from entering the changes needed to the temp tables. ...
    (microsoft.public.access.formscoding)
  • Re: Open a query and pausing for changes
    ... Rather than manually making changes to the queries, why not use a form to swap rooms? ... All queries work except where I need to temporily stop the delete query from executing until the user has finshed updating two records that open in two different temp tables. ... What I am doing manually is getting the record info from the first room number 616 and appending to a temp table. ...
    (microsoft.public.access.formscoding)
  • Re: Can reducing number of tables improve performance?
    ... There might be less bloating with fewer temp tables, ... database that is maintainable. ... - I use a saved queries to feed the drop-down lists throughout the software, ... but are used to support different reports. ...
    (microsoft.public.access.tablesdbdesign)

Loading