lanlanzhibi
2013-10-17 06:37
采纳率: 100%
浏览 2.2k

关于设置参数值和直接拼接SQL语句问题

DECLARE @SysBranchSysNo int,@C1SysNo int,@RepeatNum INT
SET @SysBranchSysNo=1;
SET @C1SysNo=1073;
SET @RepeatNum=1
SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY Quantity desc ) AS DATA_ROW_NUM, * FROM (
SELECT * FROM (SELECT ROW_NUMBER() OVER(PARTITION BY SysNo,SysBranchSysNo ORDER BY totalNum) as RepeatNum,* FROM dbo.v_product) Product
WHERE SysBranchSysNo=@SysBranchSysNo
AND C1SysNo=@C1SysNo AND RepeatNum=@RepeatNum AND onlineqty>0 ) A) B WHERE DATA_ROW_NUM BETWEEN 181 AND 200;
为什这条语句执行结果是没数据,如果把WHERE SysBranchSysNo=@SysBranchSysNo改成WHERE SysBranchSysNo=1这样的执行结果就有值了。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • lanlanzhibi 2013-10-17 08:11
    已采纳

    找到原因了,改成这样就行了
    DECLARE @SysBranchSysNo int,@C1SysNo int,@RepeatNum INT
    SET @SysBranchSysNo=1;
    SET @C1SysNo=1073;
    SET @RepeatNum=1
    SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY Quantity desc ) AS DATA_ROW_NUM, * FROM (
    SELECT * FROM (SELECT ROW_NUMBER() OVER(PARTITION BY SysNo,SysBranchSysNo ORDER BY totalNum) as RepeatNum,* FROM dbo.v_product
    WHERE SysBranchSysNo=@SysBranchSysNo
    ) Product
    WHERE C1SysNo=@C1SysNo AND RepeatNum=@RepeatNum AND onlineqty>0 ) A) B WHERE DATA_ROW_NUM BETWEEN 181 AND 200;

    点赞 评论

相关推荐 更多相似问题