The other day I had to use the SQL scripts wizard (in SSMS right click the database name, select Tasks and then Generate Scripts) to create a copy of the database. I selected all of the objects, went throught the motions and then created my new database without issue.
The wizard is a pretty good tool, but I came to realize that either I missed something or the wizard did. My newly created database didn't contain any of the triggers in the old one, and there were a bunch.
In my case, the source database was stored on a remote SQL server, so I needed to write a script that would copy all of the triggers over to the new database which I was temporarily storing locally.
Hence I came up with the script here. Before you run it, you should do a little checking.
Run the following:
SELECT * FROM sys.servers
to see if the source server is listed. If it is, you do not need to run the two EXECs:
EXEC sp_addlinkedserver @server='SOURCESQLSERVER' ... EXEC sp_dropserver @server='SOURCESQLSERVER'
When the script runs, it prints each table for which it processes (CREATEs) a trigger in the messages pane. This is so that it is easy to identify when there's an error in the CREATE step (if the names of your triggers aren't consistent or easily identifiable by which table they apply to). This was beneficial to me because I was upgrading the database compatibility level from 80 to 100 and there were a few triggers that failed to CREATE due to some minor syntax incompatibilities.
Hope this is useful to you.