我在 SQL Server 中使用存储过程,但它给了我一些重复的记录,当然我的数据库中没有重复的记录,但是我的存储过程给了我相同记录的两个实例,可以是什么错误的?如何防止我的查询给出重复记录?这是我的 SP 选择子句:
select (ROW_NUMBER() OVER (ORDER BY Review.Point desc) ) as rownumber,
Business.BusinessId,Business.BName,Business.BAddress1
,Business.BAddress2,Business.BCity,Business.BState,Business.BZipCode,Business.countryCode,Business.BPhone1,Business.BPhone2,Business.BEmail,Business.Keyword
,Business.BWebAddress,Business.BCatId,Business.BSubCatId,Business.BDetail,Business.bImage,Business.UCId,Business.UCConfirm
,Business.UOId,Business.UOConfirm,Business.x,Business.y,Cat.CatName,SubCat1.SubCatName
from Business left outer join
Review on business.BusinessId=Review.BusinessId left outer join
Cat on business.BCatid=Cat.CatId left outer join
SubCat1 on business.BSubCatid=SubCat1.SubCatId '+@sql2+'
) as tbl
where rownumber between '+CONVERT(varchar, @lbound)+' and '+CONVERT(varchar, @ubound);