I have a table with a certain amount of ids and I want to use these seperate ids to retrieve data from another table.
set @CurrentRow = 0
set @RowsToProcess = (SELECT COUNT(*) FROM @QuestionsPrimaryTable)
WHILE(@CurrentRow < @RowsToProcess)
BEGIN
DECLARE @id int
DECLARE @value varchar(200)
SET @CurrentRow = @CurrentRow + 1
SELECT @id = Q.QuestionsId FROM @QuestionsPrimaryTable Q
SET @value = (SELECT Q.QuestionPrimaryDescription FROM QuestionPrimary Q WHERE Q.QuestionPrimaryID = @id)
PRINT @value
END
the seperate id values I am trying to retrieve is 5, 7, 9
as it is at the moment I only retrieve value of 9
How can I retrieve the separate id values?