Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Mits
Starting Member
48 Posts |
Posted - 2008-10-02 : 04:03:31
|
Is there a quick way to script all the triggers for SQL 2K?thanks |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-10-02 : 04:14:10
|
Yes. E 12°55'05.63"N 56°04'39.26" |
|
|
Mits
Starting Member
48 Posts |
Posted - 2008-10-02 : 04:53:37
|
Hi Peso I was expecting how.Anyway I have managed to crack this on and here is the solution for everyone else.Declare @TRName varchar(100), @Sql varchar(250), @Trg varchar(8000), @Txt varchar(500) set @Trg = ''set @Txt = ''Declare #Cur cursor for SELECT nameFROM sysobjectsWHERE type = 'TR'open #Curfetch next from #Cur into @TRNamewhile @@fetch_status = 0 begin set @Txt = 'If Exists (Select name From sysObjects Where name = ' + Char(39) + @TRName + Char(39) + ' and type = ' + Char(39) + 'Tr' + Char(39) + ')' + char(10) set @Txt = @Txt + 'Drop Trigger ' + @TRName + char(10) set @Txt = @Txt + 'Go' select @Trg = @Trg + char(10) + sc.text from sysobjects so join syscomments sc on so.id=sc.id where 1=1 and so.xtype in ('TR') and so.name = @TRName order by so.id, sc.colid print @Txt + char(10) + @trg set @Trg = '' set @txt = '' fetch next from #Cur into @TRName endclose #Cur deallocate #curMits |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-02 : 04:57:06
|
In Enterprise Manager, on the database you arelooking at, select [generate SQL scripts].Untick [Script All Objects]Tick [All Tables]Under the [Formatting Tab] untick everything.Under the [Options] tab, tick [Script Triggers]and give Save as a file and click [OK] |
|
|
|
|
|