I\'ve created this stored procedure which dynamically creates the same trigger for all my tables:
USE [MyDatabase]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIE
create or alter procedure mypro
@msg varchar(20)
as
print(@msg)
go;
exec mypro @msg='fft';
Incorrect syntax near 'go'
Started executing query at Line 1
Msg 102, Level 15, State 1, Procedure mypro, Line 6
Incorrect syntax near 'go'.
;
after go it will work.create or alter procedure mypro
@msg varchar(20)
as
print(@msg)
go;
exec mypro @msg='fft';
[12:17:59 pm] Started executing query at Line 1
Commands completed successfully.
[12:17:59 pm] Started executing query at Line 7
fft
Total execution time: 00:00:00.062