• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1614
  • Last Modified:

DOS Batch variable in isql

Is it possible to pass a DOS batch variable like a database name into an isql script. For example could I pass my variable "%1" into the create database command
(isql> create database "%1"....) to automatcially create a database name as specified in the batch calling the isql command?  How??
0
wcampb_ell
Asked:
wcampb_ell
1 Solution
 
albertspCommented:
Try this the following batfile. You should modify it in the create database section. I know nothing about your devices. Probably pass thos with a variable too.

Succes, Albert

----------------------------------------------------------------------------------------------

@echo off
:: -------------------------------------------------------------------------
:: Shows sp_spaceused output for the given database
::
:: Parameters: 1: SQL Server name
::             2: Database name
::             3: Password
:: -------------------------------------------------------------------------
if  X%1X == XX goto USAGE
if  X%2X == XX goto USAGE
if  X%3X == XX goto USAGE

set SERVER=%1
set DBNAME=%2
set PASSWD=%3

set TBLSQL=CR_DB.SQL
set TBLOUT=CR_DB.OUT

>  %TBLSQL% echo use  master
>> %TBLSQL% echo set  nocount on
>> %TBLSQL% echo go
>> %TBLSQL% echo create database %DBNAME%
>> %TBLSQL% echo on datdev.dat = ...
>> %TBLSQL% echo log on logdev.dat = ...
>> %TBLSQL% echo go

c:\sybase\bin\isql -Usa -P%PASSWD% -S%SERVER% -i %TBLSQL% -o %TBLOUT%

::if exist %TBLSQL% del %TBLSQL%
set SERVER=
set DBNAME=
set TBLSQL=
set TBLOUT=

goto END

:USAGE
echo ---------------------------------------------------------------------------
echo Usage: cr_tab servername, dbname,Password
echo Creates database on given server
echo ---------------------------------------------------------------------------
:END

-----------------------------------------------------------------------------------------------
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now