I wrote this to allow me to send a priority list of int ids.
This takes a "," seperated list of integers and puts them into a table, along with an [insorder] field that allows you to sort them.
eg 2,6,3,1,7 becomes
Depending on what sort of query plan you need you could move the primary key to the insorder field
A short but interesting article, the author has figured out a way to create a PDF from a stored procedure without using a third party library.