Geeks With Blogs

Arthur Zubarev Compudicted

I was doing some new CLR Stored Procedures in SQL Server 2005 and at a certain point received error:

CREATE ASSEMBLY failed because method 'MyMethod' on type 'StoredProcedures'
in safe assembly 'MyAssembly' is storing to a static field. Storing to a static field is not allowed in safe assemblies.

Interestingly, despite all the procedures inside SQL CLR stored procedures have to be declared as static, no static fields are allowed outside them. So in my case declaring a static variable outside SqlProcedure.

[Microsoft.SqlServer.Server.SqlProcedure]

attribute caused this error.

So if you really want to share state outside stored procedures using SQL Server 2005 you will need to be creative.

In SQL Server 2008 this can be done using table variables.

Posted on Tuesday, June 30, 2009 2:59 PM | Back to top


Comments on this post: CREATE ASSEMBLY Failed Error

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Compudicted | Powered by: GeeksWithBlogs.net