Steps to follow:
- enable CLR for triggers
EXEC sp_configure 'clr enabled', 1;
GO
reconfigure
GO
- Change strict security to 0 Modify installation to account for "CLR strict security" in SQL Server 2017 tSQLt-org/tSQLt#25
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'clr strict security', 0;
RECONFIGURE;
- build assembly using visual studio
after you have built the assembly using visual studio (This will give you a dll file), create assembly in SQL server using following command
alter database epglobal set trustworthy on;
GO
CREATE ASSEMBLY CLRTrigger
FROM 'path of the dll file'
WITH PERMISSION_SET = ALL
GO
now create the trigger
CREATE TRIGGER test
ON dbo.customer
FOR INSERT, UPDATE, DELETE
AS
EXTERNAL NAME CLRTrigger.Triggers.SqlTrigger1;