i want generate script trigger as bellow
i want generate script trigger as bellow
IF
NOT EXISTS (SELECT * FROM sys.triggers WHEREobject_id = OBJECT_ID(N'[dbo].[TriStockadjustmentDelete]'))EXEC
CREATE TRIGGER [dbo].[Sample]
ON [dbo].[customerTable]
AFTER delete
AS
BEGIN
.......
END '
dbo.sp_executesql @statement = N'
Using c sharp code my code uploaded
Create script of trigger
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Mahesh ChandRank #1 · 393.3K reputationPosted Mar 10, 2011, 6:02 AM EST
Do you know the table name, trigger name and all other variables you need in a Trigger SQL syntax? If yes, you just need to build a string with some hardcoded values and some variables.
string triggerString = "CREATE TRIGGER [dbo." + TableName + "] ON " .. and keep building your string.
Suthish NairRank #92 · 22.8K reputationPosted Mar 12, 2011, 7:48 AM EST