Assuming that your YEARS table is something like this:
CREATE TABLE YEARS(Year INT)
And your YearMonths table is something like this:
CREATE TABLE YearMonths(Year INT, Month Int)
You can do something like this:
WITH CTE AS (
SELECT 1 AS Mnth
UNION ALL
SELECT Mnth + 1 FROM CTE
WHERE Mnth < 12)
INSERT INTO YearMonths (Year, Month)
SELECT Year, Mnth FROM YEARS CROSS APPLY CTE
ORDER BY Year, Mnth
This approach uses a recursive Common Table Expression (available since SQL Server 2005) to build list of integer 1-12 and then cross applies it to Years table to build final list.