Mark Gilbert's Blog

Science and technology, served light and fluffy.

SSMS Scripter Introduction

As part of my company’s “Do Something Cool Day”, I wrote the kernel of what would become the SSMS Scripter.  Actually, the original name of the project was “SSMS Scriptor”, but that was before I realized that I had been misspelling the word “scripter”, so unfortunately you’ll see both variations through the code.

The Scripter creates DROP and CREATE statements for Views, Stored Procedures, and User-Defined Functions in the same format as SQL Server 2000 Enterprise Manager (SSEM) did.  SQL Server 2005 Management Studio (SSMS) changed how the scripts are generated, and you can no longer get the DROP and CREATE statements in a single script  – you have to generate two different scripts, and then merge them together.

Additionally, the built-in scripting features of SSMS would add a comment line about each object scripted.  While this doesn’t affect the quality of the script functionally, it tends to make it slightly more difficult to read.

These two changes have wreaked untold disturbances in the Force, so I set out to write my own plug-in for SSMS to create the scripts in the SSEM-style, and try to set the galaxy to rights.  I unveiled the official 1.0 release of the Scripter at the December 7, 2006 Microsoft Developers of Southwest Michigan (MDSM) user’s group meeting.  Since then, I’ve extended the application to its current 2.0 version.  The latest source code can be found here: https://markegilbert.wordpress.com/ssms-scripter/ (also available via the “SSMS Scripter” tab at the top of this blog). The Scripter is currently at version 2.0, and links itself into several levels of the SSMS hierarchy for a given database:

  • Database 
  • “Views” folder 
  • Individual views 
  • “Programming/Stored Procedures” folder 
  • Individual stored procedures 
  • “Programming/Functions” folder

The Scripter allows you to specify which objects or groups of objects to script out, and then gives you three choices of destination: a specific “.SQL” file, the clipboard, or a preview window.  Among other things, my intention in describing the SSMS Scripter’s innards is to provide a source of documentation on how to build a plug-in for SSMS.  As Part 2 of my series on the Scripter explains, official documentation from Microsoft on the classes utilized for the plug-in itself are apparently still safely locked away in the minds at Redmond.

My next three blog postings will explore the Scripter’s various noteworthy aspects:

  • SQL Management Objects 
  • Building a SSMS Plug-in 
  • Opening a form with a new Thread

I hope you enjoy using this utility, and I welcome any feedback you have on its design, features, or performance. 

Advertisements

December 15, 2006 - Posted by | SQL Server, Tools and Toys

Sorry, the comment form is closed at this time.

%d bloggers like this: