Given a scenario that could be solved with either T-SQL or the SQL CLR, how should I determine which to use?
The best advice I can offer is this: when in doubt, write some proof-of-concept code, test it in an environment that will approximate the desired scenario, and see what happens. Take the prime-number-generating stored procedure as an example. For small sets of numbers, I expected that the two approaches would yield similar performance numbers and that the overhead of switching to the SQL CLR would be roughly equivalent to the overhead of creating the temporary table. For larger sets of numbers, I expected that the SQL CLR could would be more efficient. I further expected that as the size of ...