--Products
SELECT * FROM ##products
SELECT * FROM ##products
WHERE code = 'E11'


--Fill Down
DECLARE @DB_CURSOR as CURSOR;
DECLARE @previous_product_line CHAR(120);
DECLARE @current_product_line CHAR(120);
BEGIN 
	BEGIN TRANSACTION
	SET @DB_CURSOR = CURSOR FOR
		select trim(product_line)
		from ##products
	OPEN @DB_CURSOR;
	FETCH NEXT FROM @DB_CURSOR INTO @current_product_line
	WHILE @@FETCH_STATUS =0
	BEGIN
	  --print ' current: '+@current_product_line
	  IF @current_product_line is null
		  BEGIN
			--print 'product line null'
			UPDATE ##products
			SET product_line = @previous_product_line
			WHERE CURRENT OF @DB_CURSOR
		  END
	  ELSE
		BEGIN
			SET @previous_product_line=@current_product_line
			--print 'product line changed to '+@current_product_line
		END
	  FETCH NEXT FROM @DB_CURSOR INTO @current_product_line
	END
	PRINT 'Finished'
	COMMIT TRANSACTION
END;
CLOSE @DB_CURSOR;
DEALLOCATE @DB_CURSOR;

SELECT * FROM ##products

DELETE FROM ##products
WHERE product_line IN ('Golf Equipment','Personal Accessories')


