I have the stored procedure where i am accepting the date
as input parameter for the previous month and current
month. The stored Procedure is as follows :
CREATE proc spDataTransfer_Monthly(@PrevStartDate char
(20),@PrevEndDate char (20),@CurrStartDate char
(20),@CurrEndDate char
(20),@Prevtblpostfix char (8),@Currtblpostfix char (8))
AS
BEGIN
declare @sqlstr varchar(5000)
SET NOCOUNT ON
--============= DATA TRANSFER ================
--Previous Month Table
select @sqlstr = 'INSERT INTO dbo.SHIFT'+ rtrim
(@Prevtblpostfix) +'
SELECT DISTINCT T2.*
FROM dbo.[SHIFT] T2 left JOIN
dbo.SHIFT'+ rtrim(@Prevtblpostfix) +' T1 ON
T1.SHIFT_DTG = T2.SHIFT_DTG AND
T1.MACHINE_NUMBER = T2.MACHINE_NUMBER AND
T1.SHIFT_ID = T2.SHIFT_ID
WHERE T1.SHIFT_INDEX IS NULL
AND T2.shift_dtg>='''+@PrevStartDate+''' and
T2.shift_dtg<='''+@PrevEndDate+'''
--Next Month Table
select @sqlstr = 'INSERT INTO dbo.SHIFT'+ rtrim
(@Currtblpostfix) +'
SELECT DISTINCT T2.*
FROM dbo.[SHIFT] T2 left JOIN
dbo.SHIFT'+ rtrim(@Currtblpostfix) +' T1 ON
T1.SHIFT_DTG = T2.SHIFT_DTG AND
T1.MACHINE_NUMBER = T2.MACHINE_NUMBER AND
T1.SHIFT_ID = T2.SHIFT_ID
WHERE T1.SHIFT_INDEX IS NULL
AND T2.shift_dtg >= '''+@CurrStartDate+''' and
T2.shift_dtg <= '''+@CurrEndDate+'''
SET NOCOUNT OFF
END
GO
--To Execute Stored Proc.
exec
spDataTransfer_Monthly '01/01/2003','01/31/2003','02/01/200
3','02/28/2003','_2003_1','_2003_2'
How can i pass the date value to the above stored
procedure dynamically since this stored procedure is
running in through DTS on Daily basis.