Saturday, February 25, 2012

data access in SqlUserDefinedAggregate

i'm trying to access the DB from the "Accumulate" method in my SqlUserDefinedAggregate. but i get the error:

Data access is not allowed in this context. Either the context is a function or method not marked with DataAccessKind.Read or SystemDataAccessKind.Read, is a callback to obtain data from FillRow method of a Table Valued Function, or is a UDT validation method.

the problem is that DataAccessKind only exists in SqlMethodAttribute and SqlFunctionAttribute. and they are not good for aggregate functions.

i've tried to call another class (class file that is not defined as aggregate or sql function) in the same project to do this but i still get this message if its calles from my "Accumulate" method .

Did you read the following from:

Using CLR Integration in SQL Server 2005

"Also, a UDA can perform no data access, nor have side-effects; if either of these are necessary then a stored procedure should be used.Also, a UDA can perform no data access, nor have side-effects; if either of these are necessary then a stored procedure should be used."

Jens K. Suessmeyer.

http://www.sqlserver2005.de

No comments:

Post a Comment