SBS Software Home Page   SQL2SSScripter Home Page

SQL to Sourcesafe Scripter v2.0 (SQLScripter) for Windows

Table Of Contents

Overview, what is SQLScripter?

SQLScripter is a 32 bit windows application designed as a tool that automatically generates SQL scripts for Microsoft SQL Server databases, and stores them in file system or under Microsoft SourceSafe version control. Although recent versions of MS SQL Server support version control on stored procedures through SourceSafe integration, the procedure requires modifications to be done exclusively from within a MS Visual Studio interface, and does not apply to other schema information such as table or view scripts. SQLScripter proposes a solution where all development work is done as before on the real server, and all schema objects are scripted into SourceSafe at predefined intervals. Interested parties are notified of changes by automatic e-mails where created, altered or dropped objects are reported.

The individual database programmer may benefit from SQLScripter in keeping a personal history of versions. However the real value of SQLScripter comes out in collaboration, where a possibly multi-site group of programmers are working on related databases. If the volume of shared development is very high, a project may indeed call for a disciplined old-fashioned check-out-check-in mode of database operations to avoid collisions. Otherwise, which is the case for most mature projects in maintenance, this may be overkill. A daily run of SQLScripter may be enough to make everyone aware of any changes, and still be able roll back if necessary.

Change History
  • 2005/10/20 v2.0.1
    • Some minor bug fixes
    • Forgotten emailing development codes removed.
    • Logo image added to setup pack
  • 2005/09/27 v2.0.0 released.
  • 2004/01/23 v1.0.0 released.
TOC 
Installation, how to setup?

The latest release setup package of SQLScripter can be downloaded from here.
This application uses Microsoft SourceSafe Type Library and Microsoft SQL-DMO Type Library, which are installed by setup.
TOC^ 

Operation, how it works?

The program processes the configuration file in sequence. For each each matching object in SQL Server, it first generates the object's SQL script into its temporary files directory specified in the configuration. It then compares this file to the version in SourceSafe, internally noting the the file as changed, unchanged or new. Then the SourceSafe version is checked-out (without getting a local copy) and the scripted version is checked in. When all objects are processed like this, the program recurses in SourceSafe to find files that match the configuration but have not been scripted in this run. These files are assumed to have been dropped, and are renamed with the prefix __DROPPED_ , and go into the notification e-mails as dropped. Finally, notification mails are sent and the program terminates.

For the first run, since no objects yet exist in SourceSafe, all objects will be noted as new and according to database e-mail recipients may receive huge reports. To prevent this, see the Noreport setting in the SQL Server section section, which disables the notification e-mails as well as cross-checking for dropped objects.

The log file contains entries for the program start, termination, summary info and any error messages.
Currently this application is limited to 3 database and 100 objects to script. If you like this application and want to script more objects contact me  

TOC 

Usage, how to use?

SQLScripter is a batch tool, primarily intended for scheduled use. Based on a configuration file, it starts scripting as soon as it is run. The configuration file is in INI format and needs to be edited manually. See the next section for details. The program can be run without parameters:

SQL2SS.exe

In this case it looks for the configuration file SQL2SS.INI in the same directory as the executable (not in the working folder).

Otherwise a configuration file can be specified manually:

SQL2SS.exe sample.ini

If there is an error in loading the configuration file, an error log will be created in the executable directory. Provided that the configuration is normally loaded and it specifies a valid log file location, any other errors are logged to that file without visual prompting. Note that the notification e-mails also contain the error entries written to the log file.

Typical usage is scheduling SQLScripter as a nightly job. If scripting multiple servers in sequence takes too long, the batch job can be divided into multiple configuration files (e.g. one for each SQL Server) and scheduled as independent jobs to run in parallel. In that case, be sure to specify different log files and temporary directories to avoid concurrency conflicts.

TOC 

Configuration, how to configure?

Configuration INI file section and key details:
[GLOBAL]
Charset HTML output and email character set.
[SQL2SS_Scripter]
TempFolder Temporary script saving path.
LogFile The log file path. The file and the containing directory hierarchy are automatically created if they do not exist. The expression %AppPath% may be used in the value, and is expanded to the executable's path without the trailing backslash. The expression %Date% may be used in the value, and is expanded to the current date in YYYYMMDD format. Ex: %AppPath%\Logs\Log_%Date%.txt
Other variables : %DateTime% current date in YYYYMMDD_HHMMSS format.:
TempFolder Temporary script saving path.
DefaultExt Default file extension for created scripts
PermDataDir Permanent data folder. Scripts saved to this folder will not be deleted unles PermDataKeep flag is 0.
PermDataKeep If this flag is 1 then scripts moved to permanent data folder will be left there and not deleted.
AfterDbSrvTrg After finishing processing one sql server, program runs this trigger in shell. (i.e. a Batch file)
AfterCatTrg Trigger to run after finishing a catalog (SQL Server database).
[AfterTrigger]
RunX Triggers to run after finishing all the jobs. X must be a number starting from 1. i.e Run1, Run2... Run10
[SCC]
scccheck Source code control check, if 0 check ignored
sccget Source code control get, if 0 no scripts pulled from Visual SourceSafe
sccsave Source code control save, if 0 no scripts checked in to.
sccname SourceSafe name
sccpath SourceSafe ini full path
sccroot SourceSafe data root i.e $/SQLScripts
sccuser SourceSafe username
sccpass SourceSafe password
[SQL_XX] XX is a two digit number starting from 01
Ignore 0 or 1, If 0 then this sql server will be processed. Set 1 to temporary disable scripting this sql server without deleting the settings
DbSrvName SQL Server name
Login SQL Server Login username
DbSrvPass SQL Server Login password
Objects Objects to script, options : user, all
DbName_XX Specific database to script, XX is two digit number, starting from 01. If no dbname defined then all databases will be processed according to Objects setting.
Noreport 0 or 1, If 1 then after processing all scripts no reports sent about this server operation by email
[Mail_XX] XX is a two digit number starting from 01
MailDsb 0 or 1, Set 1 to temporary disable this email option without deleting the settings
SmtpSrv SMTP server host to send email.
SmtpUser Set If smtp server requires authentication.
SmtpPass Set If smtp server requires authentication.
From From email address
ReplyTo ReplyTo email address
Tag Prefix tag will be put in subject between square brackets as a prefix. i.e if Tag=CorpSQL subject starts with [CorpSQL]
This is usefull for email archiving purposes. (applying rule to move to a specific folder etc)
ToX X is number starting from 1. To email address.
SkipOthersIfOk 0 or 1 , If set to 1 and email sent successfully then skip following email options.
SendMethod 0 or 1, If 0 email sent by JMail component, if 1 email sent by ASPEmail component.
ItemFormat

Item listing format in summary report. Sample

ItemFormat=%ObjType% <A href="http://www.abc.com/ss2web/ss2web.asp?p=%Spec%">%DB%.%OwnerExc%.%Name2Show%

Variables:
%ObjType% Table, Stored Procedure etc.
%Spec%
%Db% Database name
%OwnerExc% Owner exclusion
%Name2Show% ObjectName

Sample configuration file is as follows:

Sample.INI:


[GLOBAL]
CharSet=iso-8859-9

[SQL2SS_Scripter]
tempfolder="%AppPath%"
logfile="%AppPath%\Log\Log_%DateTime%.txt"
DefaultExt=SQL
permdatadir="%AppPath%\Data"
permdatakeep="1"
AfterDbSrvTrg=""
AfterCatTrg=""

[AfterTrigger]
;Run1=test.bat

[scc]
scccheck=0
sccget=0
sccsave=0
sccname=LocalVSS
sccpath="\\server1\vssdb\srcsafe.ini"
sccroot="$/SQL"
sccuser="SQLScripter1_vss"
sccpass=""

[SQL_01]
ignore=0
dbsrvname="TESTSQL1"
Login="SQLScripter"
dbsrvpass=""
objects="user"
Noreport=0

[SQL_02]
ignore=0
dbsrvname="TESTSQL2"
Login="SQLScripter"
dbsrvpass=""
objects="user"
Noreport=0
DbName_01=Pubs

[Mail_01]
maildsb=0
smtpsrv="smtp.abc.com"
smtpuser=""
smtppass=""
From="admin@abc.com"
ReplyTo=""
Tag="PREFIXTAG"
To1=admin@abc.com
To2=sqloperator@abc.com
SkipOthersIfOk=1
SendMethod=0

ItemFormat=%ObjType% <A href="http://www.abc.com/ss2web/ss2web.asp?p=%Spec%">%DB%.%OwnerExc%.%Name2Show%

 

TOC 

Download

SQL2SS.zip (3.5 MB) Windows (MSI) Installer package, just MSI file
SQL2SSwSetup.zip (6.5 MB) Full Setup with Installer


Some prerequisites:
Windows Update, Do not forget to update your Operating System

Installation of this product requires the Windows Installer version 2.0+. If you are running Windows 95, 98, or Windows NT, you may need to download the proper installer for your system, and run it before you can install this product.

For Windows 98:
http://www.microsoft.com/downloads/release.asp?ReleaseID=32831

For Windows NT:
http://www.microsoft.com/downloads/release.asp?ReleaseID=32832

For Windows 2000/XP/2003:
Windows Installer 3.0 Redistributable

If you have problems, suggestions, do not hesitate to contact me from ssubasi@sbscon.com

 

Copyright © 1996 - 2005 SBS Software (Serkan SUBASI)  ISTANBUL TURKIYE. All rights reserved.
@: sbs@sbscon.com