PreacherUK
Technical User
Hi all,
Below is the code I am using in my stored procedure. I want to pass in the date. I will be taking this date from a field in a table. I am extracting this date with the following query:
SELECT TOP 100 PERCENT Proc_Date
FROM dbo.tblGLNLoanall
GROUP BY Proc_Date
ORDER BY Proc_Date
How would I go about passing this date that is returned into the sp below?
I am currently using this to run my sp (for testing purposes)
DECLARE @Now AS DateTime
SET @Now = CAST('03 Mar 2004' AS DATETIME)
EXEC aaatest_output_days @Now
GO
I eventually want to run this from a DTS package as part of a larger import process using an 'Execute SQL Task' object, this should be possible yes?.
CREATE PROCEDURE aaatest_output_days
(
@Date As DateTime
)
AS
-- SET DATEFIRST to default value of 1 (Monday).
SET DATEFIRST 1
-- Declare variables
DECLARE @DayofWeek AS INTEGER
SET @DayOfWeek = (SELECT DATEPART(dw, @Date))
If @dayofweek = 5
BEGIN
-- this should run if it is friday
-- Note this is just for testing
PRINT ('IT IS FRIDAY (' + CAST (@Date As VARCHAR(11)) + ' - ' + CAST(@DayOfWeek AS VARCHAR(2))+ ')')
END
Else
BEGIN
-- this should run if it is not friday
PRINT ('IT IS NOT FRIDAY (' + CAST (@Date As VARCHAR(11)) + ' - ' + CAST(@DayOfWeek AS VARCHAR(2))+ ')')
END
GO
Thanks for any help or pointers
Dave
Below is the code I am using in my stored procedure. I want to pass in the date. I will be taking this date from a field in a table. I am extracting this date with the following query:
SELECT TOP 100 PERCENT Proc_Date
FROM dbo.tblGLNLoanall
GROUP BY Proc_Date
ORDER BY Proc_Date
How would I go about passing this date that is returned into the sp below?
I am currently using this to run my sp (for testing purposes)
DECLARE @Now AS DateTime
SET @Now = CAST('03 Mar 2004' AS DATETIME)
EXEC aaatest_output_days @Now
GO
I eventually want to run this from a DTS package as part of a larger import process using an 'Execute SQL Task' object, this should be possible yes?.
CREATE PROCEDURE aaatest_output_days
(
@Date As DateTime
)
AS
-- SET DATEFIRST to default value of 1 (Monday).
SET DATEFIRST 1
-- Declare variables
DECLARE @DayofWeek AS INTEGER
SET @DayOfWeek = (SELECT DATEPART(dw, @Date))
If @dayofweek = 5
BEGIN
-- this should run if it is friday
-- Note this is just for testing
PRINT ('IT IS FRIDAY (' + CAST (@Date As VARCHAR(11)) + ' - ' + CAST(@DayOfWeek AS VARCHAR(2))+ ')')
END
Else
BEGIN
-- this should run if it is not friday
PRINT ('IT IS NOT FRIDAY (' + CAST (@Date As VARCHAR(11)) + ' - ' + CAST(@DayOfWeek AS VARCHAR(2))+ ')')
END
GO
Thanks for any help or pointers
Dave