70 likes | 426 Views
SQL Management Objects / SQL Server Management Studio Plug-In. Mark Gilbert BlueGranite, Inc. The Task. Create a scripting plug-in for SSMS that creates DROP/CREATE scripts like SQL Server 2000 Enterprise Management: IF EXISTS … DROP … GO CREATE … GO. Scripting with SMO.
E N D
SQL Management Objects / SQL Server Management Studio Plug-In Mark Gilbert BlueGranite, Inc.
The Task Create a scripting plug-in for SSMS that creates DROP/CREATE scripts like SQL Server 2000 Enterprise Management: IF EXISTS … DROP … GO CREATE … GO
Scripting with SMO SQL Management Objects (SMO) are used to create the DROP and CREATE statements. See: SSMSScriptor.GenerateScripts()
Plugging In - Setup Project Properties: • Application: Class Library • Compile: Register for COM Interop • Debug: Start External Program (SSMS) • References: See PlugIn.vb comments Registry Key: HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\90\Tools\Shell\AddIns\SSMSScriptor.Plugin
Plugging In – Classes PlugIn The entry point for the plug-in MenuNode: Encapsulates all logic for adding an item to the context menus ScripterMenuItem Used when the user invokes a menu item
Future Enhancements • Allow the user to script individual user-defined functions. • Script the objects out in dependency-order • Make the scripter form itself more flexible
Resources • SMO: • http://msdn2.microsoft.com/en-us/library/ms162169.aspx • Scripting with SMO: • http://msdn2.microsoft.com/en-us/library/ms162153.aspx • http://davidhayden.com/blog/dave/archive/2006/11/09/ScriptDatabaseUsingSQLServerManagementObjects.aspx • Enisey Data Scripter (inspiration) • http://www.codeproject.com/useritems/enisey.asp