|
Posted by xAvailx on 10/23/06 16:10
For automation, I would check out the command line utilities: isql,
osql or sqlcmd depending on which version of sql server you are using.
We often run our tests from command scripts. e.g. Copy the following
into a cmd file (MyTest.cmd). You can then execute as follows:
MyTest.cmd myserver mydatabase
--------------------------------------------------
@echo off
REM: Usage: CommandFilename [Server] [Database]
if '%1' == '' goto usage
if '%2' == '' goto usage
if '%1' == '/?' goto usage
if '%1' == '-?' goto usage
if '%1' == '?' goto usage
if '%1' == '/help' goto usage
sqlcmd -S %1 -d %2 -E -b -i "MyScript.sql"
if %ERRORLEVEL% NEQ 0 goto errors
REM: More scripts...
goto finish
REM: How to use screen
:usage
echo.
echo Usage: MyScript Server Database
echo Server: the name of the target SQL Server
echo Database: the name of the target database
echo.
echo Example: MyScript.cmd MainServer MainDatabase
echo.
echo.
goto done
REM: error handler
:errors
echo.
echo WARNING! Error(s) were detected!
echo --------------------------------
echo Please evaluate the situation and, if needed,
echo restart this command file. You may need to
echo supply command parameters when executing
echo this command file.
echo.
pause
goto done
REM: finished execution
:finish
echo.
echo Script execution is complete!
:done
@echo on
--------------------------------------------------
HTH
tamatem wrote:
> I have build a long sql data load script. What is the best way to do
> Testing of the script? I would like to automate the test!
Navigation:
[Reply to this message]
|