I have created a Trigger that calls an assembly like this:
CREATE TRIGGER Testrigger ON STATION
FOR INSERT
AS EXTERNAL NAME assemblytest.[WriteTimeInfile.Program].Testrigger
The .NET code in that assembly that does something like this:
namespace WriteTimeInfile
{
public class Program
{
[SqlTrigger(Name = @"Testrigger", Target = "[dbo].[STATION]", Event = "FOR INSERT, UPDATE, DELETE")]
public static void Testrigger()
{
File.AppendAllText(@"C:\Users\Vivien\date.txt",
DateTime.Now.ToString() + Environment.NewLine);
}
}
}
I would like to be able to pass, as an argument, the created row or the updated row something like this:
CREATE TRIGGER Testrigger ON STATION
AFTER INSERT
AS
EXTERNAL NAME assemblytest.[WriteTimeInfile.Program].Testrigger (STATION.ID)
I found a 7 years old topic on StackOverflow that tells there is no way to pass an argument to a CLR assembly.
I am asking if it is now possible in recent SQL Server versions.
Do you know if there is a way and if yes how to do it please?