using System;
using System.Data;
using Microsoft.SqlServer.Server;
using System.Data.SqlTypes;
public class MyProc
{
XMLDoc config;
public MyProc()
{
config = GetConfigFromFileSystem();
}
[Microsoft.SqlServer.Server.SqlProcedure]
public static void MyProc(varchar(20))
{
// Do Stuff with varchar(20) that relies on config info
}
}
The pont being is I dont understand the life cycle of an object like
this in a SQL context.
What I really want is something like this ;
1. SQL Engine starts
2. Assembly loads and constructor is called.
3. All methods are now available to all SQL calls (like static)
If I go the 'static' route I am concerned that on each call to the
method I am going to have to get config from file each time.
This is going to hammer performance...
Can anyone offer advice ? I really want a singleton
Rgds
s
Note that if you have a static member, the assembly needs UNSAFE permission.
--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se
Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx