Solved

DOS Batch variable in isql

Posted on 2000-04-27
1
1,585 Views
Last Modified: 2012-05-04
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
Comment
Question by:wcampb_ell
1 Comment
 
LVL 1

Accepted Solution

by:
albertsp earned 50 total points
ID: 2758718
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Owning a franchise can be the dream of a lifetime. It provides a chance for economic growth. You can be as successful as you want.  To make your franchise successful, you need to market it successfully. Here are six of the best marketing strategies …
Is your company's data protection keeping pace with virtualization? Here are 7 dynamic ways to adapt to rapid breakthroughs in technology.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now