Thursday, October 27, 2011

"The database owner SID recorded in the master database differs from the database owner SID recorded in database" - SQL CLR DLL Register error in SQL Server

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.

Lt's show you the script so you have more idea. We have a script to register DLL as following,

SP_CONFIGURE 'clr enabled',1
GO
RECONFIGURE
GO

USE SQLCLRDb 
GO

CREATE ASSEMBLY [SQLCLR_ASSEMBLY] 
FROM 'C:\SQLCLR_ASSEMBLY.dll' WITH permission_set = UNSAFE 

GO 

And the error is coming like

The database owner SID recorded in the master database differs from the database owner SID recorded in database.
You should correct this situation by resetting the owner of database using the ALTER AUTHORIZATION statement.


The solution for this issue is which we have the script below. This script will change db owner of the running database and make it trust worthy on.

USE SQLCLRDb 
GO

ALTER DATABASE SQLCLRDb SET TRUSTWORTHY ON
go

EXEC SP_CHANGEDBOWNER 'UserName'
GO

After running above query, i come out from 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.



0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...