I have the following in T-SQL:
INSERT INTO tblAttMain(Site, FirstName, LastName)
SELECT
Site, FirstName, LastName
FROM
tblAttTmp
WHERE
Site = @Site
What I am doing here is copying columns from tblAttTmp into the tblAttMain table. Note the select statement can return hundreds of rows. tblAttTmp has a primary key called ID to specify the specific ID for that record.
If for each interaction of of the select if there is an error, I like to spit out what the tblAttTmp's ID was and create a string so that I can see all of the ID's which need to be fixed.
Not sure how to do as the select is a one shot deal.