First of all you cannot specify core for thread from managed code. It is the very basic concept of managed code that all memory, threading and etc tasks are managed by VM and OS.
The second thing that you won't reach any optimization with SQL with the code I see, because SQL queries run at SQL-server, not in you code.