Hi All,
when I execute my sproc, passing a null value, I get this error:
Warning: Null value is eliminated by an aggregate or other SET operation.
here is the sproc
Create procedure dbo.Search
(@BeginDate DateTime,
@EndDate DateTime)
As
DECLARE @vBeginDate NVARCHAR(20)
DECLARE @vEndDate NVARCHAR(20)
DECLARE @vStrSQL NVARCHAR(2000)
IF @BeginDate IS NOT NULL OR @EndDate IS NOT NULL
BEGIN
IF @BeginDate IS NULL
SELECT @BeginDate = MIN(A.ApprecdDate)
FROM WQOnsite.dbo.tblApplication A
IF @EndDate IS NULL
SELECT @EndDate = MAX(A.ApprecdDate)
FROM WQOnsite.dbo.tblApplication A
SET @vBeginDate = convert(VARCHAR(12), @begindate, 102)
SET @vEndDate = convert(VARCHAR(12), @EndDate, 102)
SET @vstrsql = 'SELECT * FROM tblApplication A where a.appRecddate between ''' +
@vBeginDate + ''' and ''' + @vEndDate + ''''
END
exec (@vStrSQL)
***********************
(EXEC SEARCH '1/1/1992', NULL )gives me the right result but I get the above warnning and the same with begindate is being null.
Thank you for your help in advance
when I execute my sproc, passing a null value, I get this error:
Warning: Null value is eliminated by an aggregate or other SET operation.
here is the sproc
Create procedure dbo.Search
(@BeginDate DateTime,
@EndDate DateTime)
As
DECLARE @vBeginDate NVARCHAR(20)
DECLARE @vEndDate NVARCHAR(20)
DECLARE @vStrSQL NVARCHAR(2000)
IF @BeginDate IS NOT NULL OR @EndDate IS NOT NULL
BEGIN
IF @BeginDate IS NULL
SELECT @BeginDate = MIN(A.ApprecdDate)
FROM WQOnsite.dbo.tblApplication A
IF @EndDate IS NULL
SELECT @EndDate = MAX(A.ApprecdDate)
FROM WQOnsite.dbo.tblApplication A
SET @vBeginDate = convert(VARCHAR(12), @begindate, 102)
SET @vEndDate = convert(VARCHAR(12), @EndDate, 102)
SET @vstrsql = 'SELECT * FROM tblApplication A where a.appRecddate between ''' +
@vBeginDate + ''' and ''' + @vEndDate + ''''
END
exec (@vStrSQL)
***********************
(EXEC SEARCH '1/1/1992', NULL )gives me the right result but I get the above warnning and the same with begindate is being null.
Thank you for your help in advance