• Just for completeness here are a few things to try if your CLR performance is unacceptable.

    1) Despite the title of this thread, DO use SqlBulkCopy - its much faster than the DataAdapter.Update() method - which does an update for every changed datarow.

    2) Do sorting in T-SQL - I used BulkCopy to write out the datatable to a pre-created temp table, which had a clustered primary key on my sort field

    3) Read in a DataReader if you don't need to change the data - so now I read the temp table ordered by its primary key, and process the contents I do all my processing into a new dataTable which uses appropriate PrimaryKey settings

    4) Do Joins in T-SQL - again bulkcopy back to the T-SQL, and to get the join results, use a DataAdapter with SqlCommand that does the appropriate JOIN

    5) You can do most things T-SQL with a DataAdapter's SqlCommand - e.g. DELETE, TRUNCATE, INSERT INTO, call other stored procedures ... anything set-based, get Sql Server to do it

    My 60-second proc is now around 20 sec .. and I still have a couple of things to try ..