SBS Software Home Page   SQL2SSScripter Home Page

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

Table Of Contents
Overview, what is SQLScripter?

SQLScripter is a 32 bit windows application designed as a tool that automatically generates SQL schema 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 Visual 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 (Schema Change History) where all development work is done as before on the real server, and all database 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. This tool can also be used as a change and configuration management for SQL Server.

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 (What's new?)
  • 2006/09/27 v2.0.4
    • Minor bug fixes and some improvements
    • Content scripting function added. (Data Scripting as insert statements) Sample content script output
    • Configuration section bug fixed.
  • 2006/01/22 v2.0.3
  • 2006/01/06 v2.0.2
    • Some minor bug fixes
    • Improved Error handling
    • Now It can compare script files without using Microsoft Visual Sourcesafe.
  • 2005/10/20 v2.0.1
    • Some minor bug fixes
    • Logo image added to setup pack
  • 2005/09/27 v2.0.0 released.
    • Logic changed, and most of the code is rewritten.
  • 2004/01/23 v1.0.0 released.

Credits

Idea Inspired from Zafer Barutcuoglu
Some portions coded, edited by Emre Ongun, Fulya Isik
Mostly rewritten and utilized by Serkan Subasi

Top
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.

^Top^
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  

Top
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 or hourly 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.

Top
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.:
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.
BeforeDbSrvTrg Before starting processing one sql server, program runs this trigger in shell. (i.e. a Batch file)
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 in plain text, you can use either one of sccpass or sccpassenc to set sourcesafe user password
sccpassenc SourceSafe password in encrypted format
sccdontmarkdropped Do Not Mark objects as dropped
[SQL_XX] XX is a two digit number starting from 01 (with leading zero)
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. If you do not want the password to be seen in plain text here, use DbSrvPassEnc parameter to set the password
DbSrvPassEnc SQL Server Login password in encrypted format
Objects Objects to script, options : user, all
StripConstraint 0 or 1. Default 0. Recommended 1. If set to 1 then constraint names stripped from T-SQL.
StripCollation 0 or 1. Default 0. If set to 1 then collation names stripped from T-SQL.
DBs2Exclude Databases to exclude, names delimited with semicolon (;)
This option is only used when no database defined specifically with DbName_XX
Tables2ScrContent Tables to script content as insert statements, names delimited with semicolon (;), * scripts all tables data
Tables2ScrC_MaxRow Maximum row count to script
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
StripConstraint_XX 0 or 1. Default 0. Recommended 1. If set to 1 then constraint names stripped from T-SQL.
XX is two digit number, starting from 01.
StripCollation_XX 0 or 1. Default 0. If set to 1 then collation names stripped from T-SQL.
XX is two digit number, starting from 01.
Tables2ScrContent_XX Tables to script content as insert statements, names delimited with semicolon (;), * scripts all tables data
Tables2ScrC_MaxRow_XX Maximum row count to script
[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  To email address. X is number starting from 1.
SkipWhenNoChange 0 or 1, Default 0, If set to 1 and nothing changed in scripts and no errors occurred processing then no email sent to this setting.
SkipOthersIfOk 0 or 1, Default 0, 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. Samples
ItemFormat=%ObjType% <A href="http://www.abc.com/ss2web/ss2web.asp?p=%Spec%">%DB%.%OwnerExc%.%Name2Show%</A>
ItemFormat=%InRowNo% %OwnerExc%.%Name2Show%
Variables:
Variable name (Case Insensitive) Definition
%ObjType% Object type. Table, Stored Procedure etc.
%Spec% Coded source code control path parameter, Used by asp page.
%Db% Database name
%Owner% Object Owner
%OwnerExc% Owner excluded (show object owner only if not dbo)
%Name2Show% Object Name
%RowNo% Global Process Row number (For debug purposes)
%InRowNo% Inner row number (Row number of item for current section)
Top 

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"
BeforeDbSrvTrg="init.bat"
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=""
;dbsrvpassenc=""
objects="user"
Noreport=0
StripConstraint=1
StripCollation=0
DBs2Exclude=Pubs;TestDb1;TestDB2

[SQL_02]
ignore=0
dbsrvname="TESTSQL2"
Login="SQLScripter"
dbsrvpass=""
objects="user"
Noreport=0
StripConstraint=0
StripCollation=0
Tables2ScrContent=UserTypes;LookupTable;Countries;States;
Tables2ScrC_MaxRow=200

DbName_01=Pubs
StripConstraint_01=1
StripCollation_01=0
Tables2ScrContent_01=PubsStates;
Tables2ScrC_MaxRow_01=300

DbName_02=NorthWind
StripConstraint_02=0
StripCollation_02=1

[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
SkipWhenNoChange=0
SkipOthersIfOk=1
SendMethod=0
ItemFormat=%ObjType% <A href="http://www.abc.com/ss2web/ss2web.asp?p=%Spec%">%DB%.%OwnerExc%.%Name2Show%</A>
Top

Sample Schema Script Output: (Jobs table from Pubs database)

CREATE TABLE [dbo].[jobs] (
	[job_id] [smallint] IDENTITY (1, 1) NOT NULL ,
	[job_desc] [varchar] (50) NOT NULL DEFAULT ('New Position - title not formalized yet'),
	[min_lvl] [tinyint] NOT NULL ,
	[max_lvl] [tinyint] NOT NULL ,
	 PRIMARY KEY  CLUSTERED
	(
		[job_id]
	)  ON [PRIMARY] ,
	 CHECK ([max_lvl] <= 250),
	 CHECK ([min_lvl] >= 10)
) ON [PRIMARY]
GO

GRANT  REFERENCES ,  SELECT ,  UPDATE ,  INSERT ,  DELETE  ON [dbo].[jobs]  TO [guest]
GO

Sample Content Script Output: (Jobs table from Pubs database)

ALTER TABLE [jobs] NOCHECK CONSTRAINT ALL
SET IDENTITY_INSERT [jobs] ON
INSERT INTO [jobs] ([job_id],[job_desc],[min_lvl],[max_lvl]) VALUES (1,'New Hire - Job not specified',10,10)
INSERT INTO [jobs] ([job_id],[job_desc],[min_lvl],[max_lvl]) VALUES (2,'Chief Executive Officer',200,250)
INSERT INTO [jobs] ([job_id],[job_desc],[min_lvl],[max_lvl]) VALUES (3,'Business Operations Manager',175,225)
INSERT INTO [jobs] ([job_id],[job_desc],[min_lvl],[max_lvl]) VALUES (4,'Chief Financial Officier',175,250)
INSERT INTO [jobs] ([job_id],[job_desc],[min_lvl],[max_lvl]) VALUES (5,'Publisher',150,250)
INSERT INTO [jobs] ([job_id],[job_desc],[min_lvl],[max_lvl]) VALUES (6,'Managing Editor',140,225)
INSERT INTO [jobs] ([job_id],[job_desc],[min_lvl],[max_lvl]) VALUES (7,'Marketing Manager',120,200)
INSERT INTO [jobs] ([job_id],[job_desc],[min_lvl],[max_lvl]) VALUES (8,'Public Relations Manager',100,175)
INSERT INTO [jobs] ([job_id],[job_desc],[min_lvl],[max_lvl]) VALUES (9,'Acquisitions Manager',75,175)
INSERT INTO [jobs] ([job_id],[job_desc],[min_lvl],[max_lvl]) VALUES (10,'Productions Manager',75,165)
INSERT INTO [jobs] ([job_id],[job_desc],[min_lvl],[max_lvl]) VALUES (11,'Operations Manager',75,150)
INSERT INTO [jobs] ([job_id],[job_desc],[min_lvl],[max_lvl]) VALUES (12,'Editor',25,100)
INSERT INTO [jobs] ([job_id],[job_desc],[min_lvl],[max_lvl]) VALUES (13,'Sales Representative',25,100)
INSERT INTO [jobs] ([job_id],[job_desc],[min_lvl],[max_lvl]) VALUES (14,'Designer',25,100)
SET IDENTITY_INSERT [jobs] OFF
ALTER TABLE [jobs] CHECK CONSTRAINT ALL

Top
Enter your email address to be informed about new releases and fixes. (Optional)
Firstname
Lastname
Email
Download

Incremental installation pack
SQL2SSv204.rar (v2.0.9) (85KB) Just Executable file (If you previously setup full installation pack)
Full installation packs
SQL2SS.zip (3.5 MB) Windows (MSI) Installer package, Setup without Installer Loader (v2.0.9)
  Rar SQL2SS_wIL.zip (6.5 MB) Full Setup with Installer Loader (v2.0.9)

* You need WinRAR or Winzip to open compressed setup packages.

= To help us improve our software, if you discover any bugs or have any improvement suggestions, please tell us.
Your feedback is very important to us. Thank you!
Do not hesitate to contact author from
ssubasi@sbscon.com


Some prerequisites:
Keep Windows Updated

All Windows users should apply the latest Microsoft security updates to help make sure that their computers are as protected as possible. If you are not sure whether your software is up to date, visit the Microsoft Update Web site , scan your computer for available updates, and install any high-priority updates that are offered to you. If you have Automatic Updates enabled, the updates are delivered to you when they are released, but you have to make sure you install them.


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, or you must download the full setup, it includes windows installer loader.

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: (optional)
Windows Installer 3.0 Redistributable


Top 



Alternate download sites

From downloadarsivi.com   From softpedia.com   From zdnet

Get it from CNET Download.com!

 

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