Welcome to Dovetail Software Blogs : Sign in | Join | Help
A few of my common utilities

Whenever I have to do something more than a few times, I like to make a shortcut or a utility for it. I have all of these in my c:\bin directory, and I have my system path set to include c:\bin.  These utilities mean that I don't have to think about a lot of heavy syntax most of the time.

For example, to import a DAT file into my database, rather than using:

c:\bin\diet.exe -license MyDietLicenseKey -user_name sa -password sa -db_server . -db_name dovetail -import file.dat -sqllog sql.log

I just have to use:

import dovetail file.dat

Much easier to remember, and much easier and quicker to type.

Most of these are geared towards running on my development system, which is primarily SQL Server running on localhost with an sa password of sa.

Here's a few common utilities that I use often. Hopefully you'll find some of them useful as well.

 

Clarify database utilities

restore_demo_db.bat

Restore database  (for Microsoft SQL Server 2005)

sqlcmd -Usa -Psa -Q "restore database demo from disk = 'C:\db_backups\clarify_mssql_58_prepared' with replace"
sqlcmd -Usa -Psa -ddemo -Q "update adp_db_header set db_name = 'demo'"

restore_125.bat

Restore database  (for Microsoft SQL Server 2000)

isql -Usa -Psa < c:\bin\restore125.sql

restore125.sql

Actual SQL to do a database restore (for Microsoft SQL Server 2000)

restore database rmcl125 from disk = 'C:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\rmcl125.bak'

delete_all_time_bombs.bat

Delete all the time bombs in my database. Good when testing RuleManager.

@echo off

if "%1" == "" goto usage

REM Hard-coded values
SET LOGIN_NAME=sa
SET PASSWORD=sa
SET SERVER=localhost

sqlcmd -Usa -Psa -d%1 -Q "delete from table_time_bomb"

goto done

:usage
echo.
echo Usage: delete_all_time_bombs db_name
echo.

:done

disable_ccn.bat

Turn off ClearContracts. Good for testing Contract Manager.

@echo off

if "%1" == "" goto usage

REM Hard-coded values
SET LOGIN_NAME=sa
SET PASSWORD=sa
SET SERVER=localhost

sqlcmd -Usa -Psa -d%1 -i disable_ccn.sql

goto done

:usage
echo.
echo Usage: disable_ccn db_name
echo.

:done

enable_ccn.bat

Turn on ClearContracts. Good for testing ClearContracts.

@echo off

if "%1" == "" goto usage

REM Hard-coded values
SET LOGIN_NAME=sa
SET PASSWORD=sa
SET SERVER=localhost

sqlcmd -Usa -Psa -d%1 -i enable_ccn.sql

goto done

:usage
echo.
echo Usage: enable_ccn db_name
echo.

:done

Clarify Utilities

ftindex.bat

Update the Fulcrum/Hummingbird full-text-search indexes

C:\Clarify\11.5\ClarifyFTIndex\ftindex.exe -user_name sa -password sa -db_server . -db_name dovetail -dir C:\Clarify\11.5\ClarifyFTIndex\index

Development Utilities

se.bat

Run Dovetail SchemaEditor

@echo OFF
"C:\Program Files\Dovetail Software\SchemaEditor\SchemaEditor.exe" %*
IF EXIST SchemaDifferenceReport.txt cat SchemaDifferenceReport.txt

nant.bat

Run nant (a .NET build tool)

C:\repo\fcsdk\trunk\tools\NAnt\nant.exe %*

ue.bat

Run UltraEdit, my text editor of choice.

"C:\Program Files\IDM Computer Solutions\UltraEdit\uedit32.exe" %1 %2 %3 %4 %5

 

ArchiveManager (DIET) Utilities

archive.bat 

Archive data out of my database.

@echo off

echo.
echo *** DIET archive utility, including license and sql logging ***
echo.

if "%1" == "" goto usage
if "%2" == "" goto usage

c:\bin\diet.exe -license LICENSE_KEY_GOES_HERE -user_name sa -password sa -db_server . -db_name %1 -export exported.dat -archive -dir %2 -sqllog sql.log

goto done

:usage
echo.
echo Missing arguments!
echo Usage: archive db_name directive_file
echo.

:done

import.bat

Import data into my database (Microsoft SQL Server)

@echo off

echo.
echo *** DIET import utility, including license and sql logging ***
echo.

if "%1" == "" goto usage
if "%2" == "" goto usage

c:\bin\diet.exe -license LICENSE_KEY_GOES_HERE -user_name sa -password sa -db_server . -db_name %1 -import %2 -sqllog sql.log

goto done

:usage
echo.
echo Missing arguments!
echo Usage: import db_name file_to_be_imported
echo.

:done

export.bat

Export data into out of my database (Microsoft SQL Server)

@echo off

echo.
echo *** DIET export utility, including license and sql logging ***
echo.

if "%1" == "" goto usage
if "%2" == "" goto usage

c:\bin\diet.exe -license LICENSE_KEY_GOES_HERE -user_name sa -password sa -db_server . -db_name %1 -export exported.dat -dir %2 -sqllog sql.log

goto done

:usage
echo.
echo Missing arguments!
echo Usage: export db_name directive_file
echo.

:done

import_ora9.bat

Import data into my database (Oracle 9)

@echo off

echo.
echo *** DIET import utility, including license and sql logging ***
echo.

if "%1" == "" goto usage
if "%2" == "" goto usage

c:\bin\diet_ora9.exe -license LICENSE_KEY_GOES_HERE -user_name sa -password sa -db_name %1 -import %2 -sqllog sql.log

goto done

:usage
echo.
echo Missing arguments!
echo Usage: import db_name file_to_be_imported
echo.

:done

purge.bat

Purge data out of my database

@echo off

echo.
echo *** DIET purge utility, including license and sql logging ***
echo.

if "%1" == "" goto usage
if "%2" == "" goto usage

c:\bin\diet.exe -license LICENSE_KEY_GOES_HERE -user_name sa -password sa -db_server . -db_name %1 -export exported.dat -purge -dir %2 -sqllog sql.log

goto done

:usage
echo.
echo Missing arguments!
echo Usage: purge db_name directive_file
echo.

:done

build_indexes.bat

Have DIET suggest and build indexes to improve the performance of purging and archiving.

@echo off

echo.
echo *** DIET index builder utility ***
echo.

if "%1" == "" goto usage
if "%2" == "" goto usage

c:\bin\diet.exe -license LICENSE_KEY_GOES_HERE -user_name sa -password sa -db_server . -db_name %1 -import %2 -eindex -pick_one

goto done

:usage
echo.
echo Missing arguments!
echo Usage: build_indexes db_name archive_file_to_be_indexed
echo.

:done

checksum.bat

Create a checksum on a directive file.

@echo off

echo.
echo *** DIET checksum utility ***
echo.

if "%1" == "" goto usage
if "%2" == "" goto usage

c:\bin\diet.exe -user_name sa -password sa -db_server . -db_name %1 -directive %2 -checksum LICENSE_KEY_GOES_HERE -archive

goto done

:usage
echo.
echo Missing arguments!
echo Usage: checksum database directive_file
echo.

:done

 

Have some scripts to share?

What about you? Have any useful utilities/scripts/snippets that you use and would like to share? You can comment here, or post to our Dovetail Forums.

Posted: Thursday, March 20, 2008 3:51 PM by gsherman

Comments

Gary Storey said:

Nice!

I hadn't thought of doing the sql restores this way.  I will definately look into that for the future.

For purging time bombs you could also use:

"truncate table table_time_bomb" . It is faster than "delete from ..." because it removes all the records at once versus deleting each row.

I do have one for schema editor (se.bat) that works similarly:

@echo off

"C:\Program Files\Dovetail Software\SchemaEditor\schemaeditor.exe" se\%1.schemaeditor %2 %3 %4 %5 %6 %7 %8 %9

I can call it with a seperate .schemaeditor file (stored in a "se" sub-directory) based on whether I am working on dev/prod or using schemascript or a full schema.

' Development SchemaScript

se.bat devss -a

' Production Schema

se.bat prod -e

and a similar setup for cbbatch:

cbbatch -db_server server -db_name database -user_name sa -password sa -f %1.cbs -r %2 -as %3 -as %4 -as %5

# March 20, 2008 4:40 PM

gsherman said:

Gary,

You're spot on with using truncate over delete. I typically have no more than a few hundred records, so the time is negligible for me - but may not be others. Good reminder.

Great idea using separate directories - one for each .schemaeditor file. I like it!

Nice cbbatch script, but I try not to use ClearBasic at all anymore. I'm all about the fcSDK now. heh

Rock on.

# March 20, 2008 7:05 PM

adp said:

# April 1, 2008 6:03 AM