ALTER PROCEDURE dbo.Addmonthslist
@BeginDate AS Datetime,
@EndDate AS Datetime,
@ProjectID AS varchar(50)
AS
SELECT
BeginDate,
EndDate
from tblProjects where ProjectID = @ProjectID
SELECT DATENAME(MONTH, DATEADD(MONTH, x.number, @BeginDate)) + '-' + Convert(varchar(4), Year(DATEADD(MONTH, x.number, @BeginDate))) AS MonthName
FROM master.dbo.spt_values x
WHERE x.type = 'P'
AND x.number <= DATEDIFF(MONTH, @BeginDate, @EndDate);
RETURN
Happy Coding!
:)