Re: Quick SQL Question
Steve Abaffy <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <006f01c797e6$5d68ccd0$183a6670$@biz> |
If I cast the fields and variables like you suggest it returns no records of any kind. -----Original Message----- From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:[email protected]] On Behalf Of William E. Booth Sent: Tuesday, May 15, 2007 9:50 PM To: [email protected] Subject: Re: [DOTNET-WINFORMS] Quick SQL Question What happens if you do something like this? CAST(UPPER(@PAddress) AS varbinary(8))<--Or whatever size it is. BETWEEN (UPPER(LowAddress) AS varbinary(8)) and (UPPER(HighAddress) AS varbinary(8)) On Tue, 15 May 2007 15:14:58 -0500, Steve Abaffy <[email protected]> wrote: >Yes this is MS SQL Server, version SQL 2000, Not sure what you mean by How >am I executing the query? I have a stored procedure > >The SQL statement from the stored procedure is below: >Where #tbl1 is a list of all address in the zipcode provided. > > >select >Zipcode,StreetPreDirection,StreetName,StreetSuffix,StreetPostDirection,Add re >ssLow, >AddressHigh,OddEven,SecondAbbrev,SecondLowNo,SecondHighNo,SecondOddEven, >Zip4 into #tbl2 from #tbl1 where SoundEx(streetname) = SoundEx (@streetname) >and @PAddress between AddressLow and AddressHigh >and OddEven in ('B',@OddEven) >and SecondHighNo IS NULL > >-----Original Message----- >From: Discussion forum for developers using Windows Forms to build apps and >controls [mailto:[email protected]] On Behalf Of Booth, >Bill >Sent: Tuesday, May 15, 2007 3:09 PM >To: [email protected] >Subject: Re: [DOTNET-WINFORMS] Quick SQL Question > >Is this MS SQL Server and what version? How are you executing the query? > > >-----Original Message----- >From: Discussion forum for developers using Windows Forms to build apps >and controls [mailto:[email protected]] On Behalf Of >Steve Abaffy >Sent: Tuesday, May 15, 2007 14:59 >To: [email protected] >Subject: [DOTNET-WINFORMS] Quick SQL Question > >Hello, > > I am writing an application that looks up addresses. The data is >broken up into prestreetdirection, streetname, poststreetdirection, >suffix, lowaddress and highaddress. All these fields are char fields as >we have lowaddress "numbers" like 312B or 31-A etc... >I have a query that basically has in its where clause, > Where @SuppliedHouseNumber between LowAddress and HighAddress > >For the value of @SuppliedHouseNumber='700' the query returns the >following two records >1) LowAddress = 700 , highAddress = 700 which of course is expected, >2) LowAddress = 700 , highAddress = 718 which of course is NOT Expected >but I don't know why. > >Any ideas and also how to get around the other problem of >SuppliedHouseAddress = 123 and returns like 1123? > >Thanks > >The information in this e-mail is confidential, may be legally privileged >and is intended solely for the addressee. If you have received this e-mail >in error, you are hereby notified that any use, distribution, or copying of >this communication is strictly prohibited.