Set Default Arguments for Stored Procedure Parameters
ALTER PROCEDURE [myProcName]
@reportingPeriodFrom varchar(10)= NULL,@reportingPeriodTo varchar(10)=NULL, @useParam int=0
AS
BEGIN
if @useParam=1
BEGIN
print('PassArugments are used')
END
else
BEGIN]
set @reportingPeriodFrom = convert(date,concat(year(getdate()),'-',month(DATEADD(MONTH,-1, getdate())),'-01') )
set @reportingPeriodTo = convert(date,concat(year(getdate()),'-',month(getdate()),'-01'))
declare @FromDate varchar(12) =concat(year(getdate()),'-',month(DATEADD(MONTH,-1, getdate())),'-01')
declare @toDate varchar(12) = concat(year(getdate()),'-',month(getdate()),'-01')
raiserror('Executing Proc with From Data %s to EndDate %s' ,1,0,@FromDate,@toDate ) with nowait
print ( concat(convert(varchar,@reportingPeriodFrom),convert(varchar,@reportingPeriodTo)) )
end