I am trying to use a temp table in SQL Server to pull ids out of a table and then loop through 12 months of the year... I can pull the products.IDs out with no problem, but when I go into the NESTED loop for the months of the year, the productID variable doesn't move with it...

```
    USE [testDB]
    GO
/****** Object:  StoredProcedure [dbo].[marketInsert]    Script Date: 06/19/2014 21:38:14     ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:      Me
-- Create date: 6/19/2014
-- Description: Insert transaction records for new markets
-- =============================================
ALTER PROCEDURE [dbo].[marketInsert] @marketID int
-- Add the parameters for the stored procedure here
AS

DECLARE @productID int
DECLARE @i int
DECLARE @imax int
DECLARE @year int
DECLARE @NumberRecords int, @RowCount int
set @imax = 12
set @i = 1
CREATE TABLE #Products (
productID int
 )
INSERT INTO #Products (productID) SELECT ID FROM products
SET @NumberRecords = @@ROWCOUNT
SET @RowCount = 1
WHILE @RowCount <= @NumberRecords
BEGIN
SELECT @productID = productID 
FROM #Products
WHERE productID = @RowCount
print @productID --WILL PRINT HERE!!!
WHILE (@i <= @imax) --loop through each month
    Begin
        --print @productID WILL NOT PRINT HERE!!!!!
        --print 'Year: ' + cast(@year as varchar(5)) + 'ProductID: ' + cast(@productID as varchar(30)) + ' Month: ' + cast(@i as varchar(2)) + ' MarketID: ' + cast(@marketID as varchar(2))

    SET @i = @i + 1 
END -- WHILE @i <= imax

SET @RowCount = @RowCount + 1
END    

BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here

END

```