If you are looping the array and pass each variables to an sp then if array contains many records then it will cause performance issues, because each time you need to contact the sqlserver.
I think the best way is make all of your id values to an xml and pass it to an sp as a parameter and there you can use xquery to process it and simply in one step you can update all values into your destination table, also you can use sql transactions for rollback because you are calling the sp only once and all insertions are happen in same time so if anything will happen wrong then sql server transaction will take care of it.
Method 1)
Example :
an example table for insertion
create table tablez1
(
id int
)
sp for insertion
IF EXISTS (
SELECT *
FROM sys.objects
WHERE type = 'P'
AND NAME = 'SpName'
)
BEGIN
DROP PROCEDURE SpName
END
GO
create procedure spname
@YourXml nvarchar(4000)
as
BEGIN TRANSACTION
BEGIN TRY
SET NOCOUNT ON
SET ARITHABORT ON
DECLARE @iinput XML;
DECLARE @xmldata XML = @YourXml
insert into tablez1
SELECT id = Adr.value('(id)[1]', 'nvarchar(max)')
FROM @xmldata.nodes('/Root/idvalues') AS Adddress(Adr)
COMMIT TRANSACTION
END TRY
BEGIN CATCH
SELECT ERROR_NUMBER() AS ErrorNumber
,ERROR_SEVERITY() AS ErrorSeverity
,ERROR_STATE() AS ErrorState
,ERROR_PROCEDURE() AS ErrorProcedure
,ERROR_LINE() AS ErrorLine
,ERROR_MESSAGE() AS ErrorMessage
END CATCH
GO
sample xml as parameter to our sp
exec spname '<Root>
<idvalues>
<id>1</id>
</idvalues>
<idvalues>
<id>2</id>
</idvalues>
<idvalues>
<id>3</id>
</idvalues>
<idvalues>
<id>a</id>
</idvalues>
<idvalues>
<id>5</id>
</idvalues>
</Root>'
Method 2)else you can use server side transactions
Method 3)use a table valued parameter
To know more about querying xml data using XQUERY- READ