Reputation: 167
I'm calling a stored procedure which contains an insert statement using another stored procedure. I am looking to perform the insert operation only if it is the first of the month. How do I add a condition in the execute statement that runs the stored procedure only on the first of each month?
I have tried the normal exec statement but am not sure how to add the first of month condition to this
EXEC SProc_test;
Upvotes: 0
Views: 1202
Reputation: 27449
Assuming you are just interested in the condition, as opposed to a method of scheduling it then the following will only run on the 1st of the month.
if datepart(day, getdate()) = 1 begin
exec Sproc_test;
end;
Upvotes: 3