I have a C# SQLCLR Stored Procedure in which first data is filled in some dictionaries and is computed and then the output is stored in some other dictionaries.
This computation is done very fast because of the usage of Dictionaries and completely justifies my need of using CLR Stored Proc instead of a normal SQL Stored Proc.
However, I have to save the data in certain tables in SQL from these output Dictionaries, and this part takes so much time and fails my need of the whole SQLCLR proc to be faster.
I have to iterate on each key of every output dictionary and then have to create Insert Query and then have to run ExecuteNonQuery in the following way:
So how can I improve my this approach so that it does not take time in inserting the data. I can't use SqlBulkCopy
as it does not accept the in-process Context Connection (i.e. "Context Connection = true;"
) as the connectionString. So is there in other faster approach available? Thanks in advance.