sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO

ALTER DATABASE CFG SET TRUSTWORTHY ON;
GO

USE CFG
GO

CREATE ASSEMBLY [ExecSqlDB] AUTHORIZATION [dbo]
FROM 'C:\Temp\CRL\ExecSqlDB.dll'
WITH PERMISSION_SET = UNSAFE;

GO

CREATE PROCEDURE [dbo].[ncspCreateUserCLR] @nvTableName [nvarchar](4000)
AS EXTERNAL NAME [ExecSqlDB].[StoredProcedures].[ncspCreateUserCLR];
GO

ALTER ASSEMBLY [ExecSqlDB]
ADD FILE FROM  'C:\Temp\CRL\ExecSqlDB.pdb'
AS N'ExecSqlDB.pdb'

GO

GRANT EXECUTE ON [dbo].[ncspCreateUserCLR] TO [nlUser]
GO