CREATE PROCEDURE [MIG_GENERATE_PROJ_CONFIG_Sp]
AS BEGIN
	-- The purpose of this stored procedure is to generate/populate the data in [MIG_SW_PROPS] table.

	DECLARE @Itr_ProjectID NVARCHAR(MAX)

	DELETE FROM MIG_PROJ_CONFIG

	--Create an entry for all users (existing in Users Table)
	INSERT INTO MIG_PROJ_CONFIG(PROJ)
	SELECT PROJECT_ID
	FROM PROJECT

	DECLARE RecordsCursor CURSOR  
	LOCAL FORWARD_ONLY FOR  
		SELECT
			PROJECT_ID
		FROM PROJECT

	OPEN RecordsCursor  
	WHILE 1 = 1   
	BEGIN
		FETCH NEXT FROM RecordsCursor INTO @Itr_ProjectID
		IF @@FETCH_STATUS <> 0
			BREAK

		exec MIG_UPDATE_PROJ_CONFIG_PREFERENCES_Sp @Itr_ProjectID
	END

	CLOSE RecordsCursor
END

-- exec MIG_GENERATE_PROJ_CONFIG_Sp
-- SELECT * FROM MIG_PROJ_CONFIG




