XML would be a better approach to IMO, although I would also recommend that you create a stored procedure to handle the actual processing instead of running an inline query.
Basically, you send the XML data as a single argument, then inside the SP you run the INSERT INTO SELECT statement, choosing from XML in some table or group of tables.
DECLARE @FOO xml; SET @FOO = '<things><thing><id>1</id></thing><thing><id>2</id></thing><thing><id>3</id></thing><thing><id>4</id></thing></things>'; SELECT ParamValues.id.value('.', 'int') AS thing_id FROM @FOO.nodes('/things/thing/id') AS ParamValues(id)
This will create a table with a single column "thing_id". Now all you have to do is something like
INSERT INTO someTable (someID) SELECT ParamValues.id.value('.', 'int') AS thing_id FROM @FOO.nodes('/things/thing/id') AS ParamValues(id)
and you've got a single INSERT to handle however many rows of XML you have.
source share