Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 .NET Inside SQL Server (2005)
 CLR Stored Procedure / Static Field

Author  Topic 

nuclearsiloman
Starting Member

9 Posts

Posted - 2007-08-06 : 13:33:09
I'm not that experienced with .net and have chosen to write a stored procedure with CLR. For the most part I've had great success in writing SPs that simply fetch a record from a database, etc, but am having trouble with calling multiple SUBs within the SP and having variables i've set along the way to be available to different SUBs.

For example, the first thing I do from the CLR code is call another SP that returns 1 recordset (5 columns). Then I need to check if a file exists on a network drive, if it does, do nothing, if it doesn't then write a file out that contains these 5 columns.

I've figured out how to do all this, except for storing the 5 columns in variables so that I can use them in the processes later.

I first attempted to declare them as 'Shared' variables, which didn't work when I tried to build the assembly (external_access) mode won't allow it and says "storing to a static field is not allowed..."

So my question is - how can I set a variable and be able to reference it from one SUB to another without actually passing in each SUB syntax.

Sorry if this is confusing...

   

- Advertisement -