Search code examples
sql-serverstored-proceduresjobs

Call methods of the SQL Server Assembly from stored pocedure in JOB


Good day to all! =) I have some problem.

There is a goup of non-static classes working with database. I decide to make a SQL Server Assembly to call them from JOB and launch by stored procedure. Never do it like this, but it seems like an interesting solution.

My code example:

public class FileProcessor
{
 public FileProcessor()
        {
            this.sqlconnect = new DBAccess();
            this.log = new Logdb();
            ExchangeService = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
        }
        public void ImportFromMail(int viborka, bool export2DB)
// operations
}

Assembly creation:

CREATE ASSEMBLY ClassLibrary1 
from 'D:\proj\csharp\test\dbclr\FileProcessor.dll'

I need to create a stored procedure to work with my object. Is it possible to get an instance of my class from assembly and call its method? HOW??? =)

Or my only way is to use COM-objects and call them from JOB?


Solution

  • Solution is simple. Need to create a class with static functions and implement non-static class as object there each time for each function. So, no need to create COM =)