If you have a fairly short array of integers, less than 250 items, this short piece of code will load it into a temp table with no loops or function calls.declare @array varchar(8000)declare @sql varchar(8000)select @array = '100,14,5,66,300,500'create table #t( num int not null primary key clustered )select @sql = 'insert into #t select '+ replace(@array,',',' union all select ') exec (@sql )select * from #tdrop table #t
Results:(6 row(s) affected)num ----------- 51466100300500(6 row(s) affected)
CODO ERGO SUM