Hi,@BenTam-3003
We cannot insert the queried data into the array,which is not supported in SQL server.
For more details about 'insert into',please refer to this document.
But we can use local table variable DECLARE @TempTable
or temporary table #TempTable
to store the result of select command .
You can also combine query results into strings or XML documents,like this:
DECLARE @STR VARCHAR(8000)
SELECT @STR=ISNULL(@STR+',','')+Stu_ID FROM Student
PRINT @STR
Best regards,
LiHong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.