Solved

script smo triggers

Posted on 2016-07-29
5
69 Views
Last Modified: 2016-08-12
Hello,

I search to exclude specific trigger like MsMerge before generate script
$scrp = new-object ('Microsoft.SqlServer.Management.Smo.Scripter') ("SQLTEST\TEST")
$scrp.Options.DriPrimaryKey=$true
$scrp.Options.Triggers=$true
$scrp.Options.AppendToFile=$true
$scrp.Options.FileName="D:\ddl\triggers_ddl.sql"

Thanks

Regards
0
Comment
Question by:bibi92
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 70

Accepted Solution

by:
Qlemo earned 500 total points
ID: 41735714
Your choices are either to export everything, then apply a text filter to remove unwanted content, or script each object individually. You can't exclude specific objects from the scripter.

Here I would use a mixed approach: script everything but triggers, then add each trigger to the script.
0
 

Author Comment

by:bibi92
ID: 41736793
Thanks. How can I apply a text filter to remove unwanted content?
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 41737708
Why not going with the last suggestion? It is much easier to write up and maintain ...
0
 

Author Comment

by:bibi92
ID: 41737868
Maybe more simple.
0
 

Author Closing Comment

by:bibi92
ID: 41754143
thanks
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question