CREATE proc GetSaleTotal @coutureid int,
@invcode   nvarchar(30),
@inventoryCategoryId int,
@priceCategoryID int,
    @startDate smalldatetime,
@endDate   smalldatetime
as
   select invcode,coutureName, sum(saleinvqty),sum(smoney),sum(costMoney)
    from v_outbilldetail
where coutureid=@coutureid and invcode=@invcode and salepriceCategoryID=@priceCategoryId and 
  (saleDate>=@startDate and saleDate<=@endDate)
 group by invcode,coutureNamego
--执行
DECLARE @RC int
DECLARE @coutureid int
DECLARE @invcode nvarchar(30)
DECLARE @inventoryCategoryId int
DECLARE @priceCategoryID int
DECLARE @startDate datetime
DECLARE @endDate datetime
SELECT @coutureid = 6
SELECT @invcode = '003'
SELECT @inventoryCategoryId = '' --这里没有条件(也就是全部条件吧?)
SELECT @priceCategoryID = '' --这里没有条件(也就是全部条件吧?)
SELECT @startDate = '2009-1-4'
SELECT @endDate = '2009-12-1'
EXEC @RC = [Couture].[dbo].[GetSaleTotal] @coutureid, @invcode, @inventoryCategoryId, @priceCategoryID, @startDate, @endDate
DECLARE @PrnLine nvarchar(4000)
PRINT '存储过程: Couture.dbo.GetSaleTotal'
SELECT @PrnLine = ' 返回代码 = ' + CONVERT(nvarchar, @RC)
PRINT @PrnLine在v_outbilldetail中是有数据的喔

解决方案 »

  1.   

    你的存储返回的是一个数据集,你这里用变量获取的是什么啊?EXEC @RC = [Couture].[dbo].[GetSaleTotal] @coutureid, @invcode, @inventoryCategoryId, @priceCategoryID, @startDate, @endDate 
    DECLARE @PrnLine nvarchar(4000) 
    PRINT '存储过程: Couture.dbo.GetSaleTotal' 
    SELECT @PrnLine = ' 返回代码 = ' + CONVERT(nvarchar, @RC) 
    PRINT @PrnLine 直接[Couture].[dbo].[GetSaleTotal] @coutureid, @invcode, @inventoryCategoryId, @priceCategoryID, @startDate, @endDate