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
Loading

Suthish NairPosted Mar 12, 2011, 12:48 PM
Mahesh ChandPosted Mar 10, 2011, 11:02 AM
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.