I have a CLR function that requires TRUSTWORTHY ON and owner of the db = 'sa' in order to function correctly.
In my deploy script I am calling this code:
Use MySecurityDB
go
EXEC dbo.sp_changedbowner @loginame = N'sa', @map = false
go
Use MyMainDB
go
EXEC dbo.sp_changedbowner @loginame = N'sa', @map = false
go
ALTER DATABASE MyMainDB SET TRUSTWORTHY ON
go
When the deploy finishes running, the owner of MyMainDB is set to my windows authenticated user name. I have to manually run the above code (which is in my deploy script) in order to allow the CLR function to work. For some reason, MySecurityDB is changed to owner SA but not MyMainDB.
Any idea on why this is? Is there another practical way to acomplish the task of setting ownership and TrustWorthy within the deploy?
Thanks in advance,
teddy