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.

 All Forums
 Development Tools
 ASP.NET
 Valid SELECT statement returns 0 records

Author  Topic 

Mondeo
Constraint Violating Yak Guru

287 Posts

Posted - 2007-09-21 : 10:43:23
I have this sql statement:

SELECT * FROM (SELECT P.vehicleref,P.manufacturer,P.model,P.derivative,P.additionalfreetext,P.isLimited,P.isPriceReduction,P.isSpecial, P.created, P.updated, NMF.term, NMF.milespa, NMF.maintained, NMF.CH, ROW_NUMBER() OVER ( PARTITION BY P.VehicleRef ORDER BY NMF.CH ) AS MinCH FROM ( SELECT * FROM vwAllMatrixSimple ) P INNER JOIN tblNewMatrixFigures NMF ON P.VehicleRef = NMF. [VehicleRef] WHERE type='Car' AND manufacturer='HYUNDAI' AND model='SANTA FE DIESEL ESTATE' AND derivative='2.2 CRTD CDX 5dr Auto [5 Seats]' AND maintained='false' AND ch >=0 AND ch <=10000 AND LOCatCode IN ('1','2','3','4','5','6')) Q WHERE MinCH = 1 ORDER BY CH ASC

It returns 0 rows using an .NET SqlCommand.

But, if I run the statement using query analyser in SQL Management Studio it returns 1 record, which is what I want.

Can anyone spot why this might be?

Thanks

Zoroaster
Aged Yak Warrior

702 Posts

Posted - 2007-09-21 : 10:53:36
Is this the query you ran in QA and got a result? Can you post the .NET sqlcommand you referenced?



Future guru in the making.
Go to Top of Page
   

- Advertisement -