Friday, February 17, 2012

Giving CLR functions rights to writes

I created a CLR function to write to a file. This of course raised a permissions error to files
The following is what I had to do to get it to work

1)Check who is the owner of the database – make sure it’s the same as master
SELECT name, SUSER_SNAME(owner_sid)
FROM   sys.databases

2)If different
ALTER AUTHORIZATION ON database::xversions TO sa;
(or EXEC sp_changedbowner 'sa')
GO

3)Create the assembly with EXTERNAL_ACCESS
create assembly TSQLFunctions
from
'c:\program files\assemblies\TSQLFunctions.dll'
WITH PERMISSION_SET=EXTERNAL_ACCESS
go

No comments:

Post a Comment