Tuesday, April 14, 2009

CLR Stored Procedure Static Exception

I was making a CLR stored procedure recently and had just added a Find Predicate to the code when the compiler gave me the message:

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

Turns out the find predicate isn't usable, but and Exists is. See Troubles with shared state and anonymous delegates in SQLCLR