zimmer9
asked on
How to pass 2 IN parameters to a stored procedure using SQL Server 2008?
I am working on a stored procedure that takes 2 IN parameters that are dates in a string format MM/DD/YYYY.
I work with SQL Server 2008.
If the stored procedure, a field dtCreated is defined as varchar(10), null in format MM/DD/YYYY
Do you know how I could rework the following Stored Procedure when 2 string date parms are passed to the Stored Proc as follows so that it filters records properly based on the 2 IN parms:
USE [CSL]
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
ALTER PROCEDURE [dbo].[proc_CSL_VoidOS] @strDateFrom NVARCHAR(10), @strDateTo NVARCHAR(10)
AS
SELECT [bank],[chkDt], [branch], [chkNum], [accountNum], [amount],[dtCreated]
FROM dbo.tbl_CSL_StopVoidPay
WHERE (dtCreated >= @strDateFrom AND dtCreated <= @strDateTo)
GROUP BY tbl_CSL_StopVoidPay.bank, ([dtCreated]), [chkDt], [branch], [chkNum], [accountNum],
[amount];
-----------
exec [dbo].[proc_CSL_VoidOS] '01/07/2003', '12/1/2009'
I work with SQL Server 2008.
If the stored procedure, a field dtCreated is defined as varchar(10), null in format MM/DD/YYYY
Do you know how I could rework the following Stored Procedure when 2 string date parms are passed to the Stored Proc as follows so that it filters records properly based on the 2 IN parms:
USE [CSL]
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
ALTER PROCEDURE [dbo].[proc_CSL_VoidOS] @strDateFrom NVARCHAR(10), @strDateTo NVARCHAR(10)
AS
SELECT [bank],[chkDt], [branch], [chkNum], [accountNum], [amount],[dtCreated]
FROM dbo.tbl_CSL_StopVoidPay
WHERE (dtCreated >= @strDateFrom AND dtCreated <= @strDateTo)
GROUP BY tbl_CSL_StopVoidPay.bank, ([dtCreated]), [chkDt], [branch], [chkNum], [accountNum],
[amount];
-----------
exec [dbo].[proc_CSL_VoidOS] '01/07/2003', '12/1/2009'
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oh, now I see. Is the date format that isn't correct. You need to pass it as YYYYMMDD:
exec [dbo].[proc_CSL_VoidOS] '20030701', '20090112'
exec [dbo].[proc_CSL_VoidOS] '20030701', '20090112'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
WHERE (dtCreated >= @strDateFrom AND dtCreated <= @strDateTo)