Recently, while working with SQL CLR functionality and created DLL for the SQL CLR. But while registering this DLL in the database I got one surprised error. Let's show you the script so you have more idea. We have a script to register the DLL as following,
SP_CONFIGURE 'clr enabled',1The error is,
GO
RECONFIGURE
GO
USE SQLCLRDb
GO
CREATE ASSEMBLY [SQLCLR_ASSEMBLY]
FROM 'C:\SQLCLR_ASSEMBLY.dll' WITH permission_set = UNSAFE
GO
The database owner SID recorded in the master database differs from the database owner SID recorded in database.The solution for this issue is which we have the script below. This script will change dbowner of the running database and make it trustworthy on.
You should correct this situation by resetting the owner of database using the ALTER AUTHORIZATION statement.
USE SQLCLRDbAfter running above query, I come out of the issue and registered SQL CLR DLL successfully. I think you also suffered same or different issues with SQL CLR. Please comment your issues and the solution for the same.
GO
ALTER DATABASE SQLCLRDb SET TRUSTWORTHY ON
go
EXEC SP_CHANGEDBOWNER 'UserName'
GO