大家好,下面是我的代码
USE [arrestedpersonsdb]
GO
/****** Object: StoredProcedure [dbo].[stnencodedtodisplay] Script Date: 08/11/2013 11:18:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[stnencodedtodisplay]
(
@PageIndex INT = 1
,@PageSize INT = 10
,@RecordCount INT OUTPUT
,@id int
,@fname varchar
,@lname varchar
)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT ROW_NUMBER() OVER
(
ORDER BY [fname] ASC
)AS RowNumber
,[pid]
,[fname]
,[mname]
,[lname]
,[qualifier]
,[alias]
INTO #Results
FROM [todisplay]
where (stnid = @id) and (type = 'STN') and (fname = @fname or @fname = '') and ( lname = @lname or @lname = '')
SELECT @RecordCount = COUNT(*)
FROM #Results
SELECT * FROM #Results
WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1
DROP TABLE #Results
END
奇怪的是,当@fname 和@lname 为空时,它返回预期的结果,但是当我尝试在@fname 或@lname 上传递参数时,它什么也不返回
下面的示例
USE [arrestedpersonsdb]
GO
DECLARE @return_value int,
@RecordCount int
EXEC @return_value = [dbo].[stnencodedtodisplay]
@PageIndex = 1,
@PageSize = 10,
@RecordCount = @RecordCount OUTPUT,
@id = 1599,
@fname = 'ALDRIN',
@lname = ''
SELECT @RecordCount as N'@RecordCount'
SELECT 'Return Value' = @return_value
GO
enter code here
但是当我将“ALDRIN”作为@fname 的参数传递时,它返回零是我的语法有问题吗?