sql server - SQL CLR trigger: name of the context DB -


I want to turn trigger triggers on / off in my SQL CLR trigger. According to me, call me

  EXEC sp_dboption '& lt; Name of db & gt; ',' recursive triggers', 'true' / 'false'  

Is there a way to know what the current DB is? On creating the trigger, I ask users to choose one, but I do not want to write it in a table.

Regards,

The SQLCLR trigger is being removed in which the database name There is a very easy way to find: Just make a connection to the connection connection and the database property does not require you to execute a query: -).

All the SQLCLR object types (stored procedure, function, user-defined consolidated, user-defined type, and trigger) should work in:

  string _DatabaseName; (Using SqlConnection _Connection = New SqlConnection ("Context Connection = true;")) {_Connection.Open (); _DatabaseName = _Connection.Database; }  

It is! I tried it just in the SQLCLR trigger and it works very well.


Keeping the trigger in mind to limit the trigger to firing other triggers is a function that works better in T-SQL triggers, where @@ PROCID < The value of / code> is available and it contains the [object_id] of the trigger, in T-SQL triggers, you can regenerate each trigger separately, but still trigger the triggers on other tables. Others can set fire to the triggers.

It can still be used in SQLCLR, but can restrict all triggers without the name of the trigger, you mean that any table is firing in any table in any table Can also prevent the trigger from stopping, but on the same table, there is no way to limit the likelihood of only , the questioner can be modified by the trigger just a reference in Use the option and SELECT TRIGGER_NESTLEVEL (); via SqlCommand.ExecuteScalar () .


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -