嗨,我有这个SP。
USE [Invoice]
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
ALTER PROCEDURE [dbo].[uspInvoiceLines]
( @InInvoiceNbr int
,@InLinesPerPage int
)
AS
DECLARE @TotalRows int
DECLARE @Remainder int
DECLARE @NumPages int
DECLARE @NextPageRows int
set @TotalRows= 0
SELECT
ROW_NUMBER() OVER( ORDER BY CONVERT(INT, InvProduct))as InvoiceRow,
CoID,
InvNo,
InvProduct,
InvDesc,
InvQuantity,
InvUOM,
InvUnitPrice,
InvAmt
into #tempInvoice
FROM Invoice_Products
SET @TotalRows= @@ROWCOUNT
IF @TotalRows=0
BEGIN
WHILE @TotalRows < @InLinesPerPage -- Add Blank Rows will generate blank invoice.
BEGIN
SET @TotalRows= @TotalRows+1
INSERT #tempInvoice
(InvoiceRow,
CoID,
InvNo,
InvProduct,
InvDesc,
InvQuantity,
InvUOM,
InvUnitPrice,
InvAmt
)
VALUES
(@TotalRows
,@InInvoiceNbr
,''
,''
,0
,0
,0
,''
,0
,0)
END
END
ELSE
BEGIN
SET @Remainder = @TotalRows%@InLinesPerPage -- get remainder
IF @Remainder !=0
BEGIN
-- Get the current page increase by 1 becasue we have a remainder.
SET @NumPages = @TotalRows/@InLinesPerPage +1
SET @NextPageRows = @NumPages * @InLinesPerPage
WHILE @TotalRows < @NextPageRows -- Add Blank Rows
BEGIN
SET @TotalRows= @TotalRows+1
INSERT #tempInvoice
(InvoiceRow,
CoID,
InvNo,
InvProduct,
InvDesc,
InvQuantity,
InvUOM,
InvUnitPrice,
InvAmt
)
VALUES
(@TotalRows
,@InInvoiceNbr
,''
,''
,0
,0
,0
,''
,0,
0)
END
END
END
SELECT * from #tempInvoice order by InvoiceRow asc
return
问题在于,在计算行号时, InvProduct 是nvarchar数据类型。所以,当我在RDL文件中使用它时,我遇到了错误。
我可以有一些想法/见解如何解决这个问题?
P.S我必须使用此SP才能显示发票类型报告,方法如下: https://www.intertech.com/Blog/use-sql-server-reporting-services-to-generate-an-invoice-document/
答案 0 :(得分:0)
您能否确认 InvDesc 是nvarchar数据类型还是int类型?如果是nvarchar数据类型,请使用&#39;&#39;而不是0。